fix(vite): disable hmr in build (#5505)

This commit is contained in:
Daniel Roe 2022-06-22 19:07:54 +01:00 committed by GitHub
parent 697f547b2c
commit e38de4af4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,9 +76,7 @@ export async function bundle (nuxt: Nuxt) {
reactivityTransform: nuxt.options.experimental.reactivityTransform
},
server: {
watch: {
ignored: isIgnored
},
watch: { ignored: isIgnored },
hmr: {
// https://github.com/nuxt/framework/issues/4191
protocol: 'ws',
@ -96,6 +94,13 @@ export async function bundle (nuxt: Nuxt) {
)
}
// In build mode we explicitly override any vite options that vite is relying on
// to detect whether to inject production or development code (such as HMR code)
if (!nuxt.options.dev) {
ctx.config.server.hmr = false
ctx.config.server.watch = undefined
}
await nuxt.callHook('vite:extend', ctx)
nuxt.hook('vite:serverCreated', (server: vite.ViteDevServer, env) => {