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

fix(vite): disable hmr in build#5505

Merged
pi0 merged 4 commits intomainfrom
fix/vite-hmr-build
Jun 22, 2022
Merged

fix(vite): disable hmr in build#5505
pi0 merged 4 commits intomainfrom
fix/vite-hmr-build

Conversation

@danielroe
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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?

Comment thread packages/vite/src/vite.ts Outdated
port: hmrPort
},
watch: nuxt.options.dev ? { ignored: isIgnored } : {},
hmr: nuxt.options.dev
Copy link
Copy Markdown
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