Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(vite): disable hmr in build #5505

Merged
merged 4 commits into from
Jun 22, 2022
Merged

fix(vite): disable hmr in build #5505

merged 4 commits into from
Jun 22, 2022

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

nuxt/nuxt#14057

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Vite tests whether hmr is truthy in deciding whether to inject certain code. We should disable this in build mode as a matter of best practice, although there shouldn't be any active bugs as we are now overriding NODE_ENV.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working vite 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Jun 17, 2022
@danielroe danielroe requested a review from pi0 June 17, 2022 13:39
@danielroe danielroe self-assigned this Jun 17, 2022
@netlify
Copy link

netlify bot commented Jun 17, 2022

βœ… Deploy Preview for nuxt3-docs canceled.

Name Link
πŸ”¨ Latest commit e544982
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62b0401e0ea3ac0008f0e04b

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! Should we also apply for other options such as watch?

port: hmrPort
},
watch: nuxt.options.dev ? { ignored: isIgnored } : {},
hmr: nuxt.options.dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor suggestion: What if after constructing initial object, we directly nullify some dev-only options like ctx.config.server.watch = false. This way we can make code simpler with less inline ? condition and also add a clear comment above why we are doing this.

@pi0 pi0 merged commit e38de4a into main Jun 22, 2022
@pi0 pi0 deleted the fix/vite-hmr-build branch June 22, 2022 18:07
@pi0 pi0 mentioned this pull request Jul 11, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x bug Something isn't working 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing vite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants