[plugin-vue] should not inject HMR code if the server is started with hmr: false
#2790
Closed
6 tasks done
Labels
hmr: false
#2790
Describe the bug
Currently,
@vitejs/plugin-vue
only checks for the existence ofoptions.devServer
(which is aViteDevServer
instance) to decide whether to inject HMR code, regardless of the actual configuration of the server.Meanwhile, there's a server option that can disable HMR completely:
vite/packages/vite/src/node/server/index.ts
Line 74 in e2b3628
and it is respected in the core vite server:
vite/packages/vite/src/node/server/index.ts
Lines 370 to 380 in e2b3628
but never checked in
plugin-vue
:vite/packages/plugin-vue/src/main.ts
Lines 116 to 136 in e2b3628
vite/packages/plugin-vue/src/template.ts
Lines 23 to 27 in e2b3628
This causes problems as I'm working on
vite-jest
.I need the transpiled code to run in the Node.js environment, which doesn't support
import.meta.hot
. But because of this bug, I can't disable HMR completely in Vue projects.Reproduction
N/A
System Info
Output of
npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:Used package manager: pnpm
Before submitting the issue, please make sure you do the following
The text was updated successfully, but these errors were encountered: