Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I turn off ViteJS's Hot Module Reload?

Tags:

nuxt.js

vite

I have a server side rendered production mode Vite application. My issue is that: routinely the webpage will reload and the console will display [vite] connecting.... I traced this back to the hot module reload portion of vite's codebase. However, I do not want hmr on for production, but it still seems to be on regardless of me setting the two settings below to false:

In my vite.config.js file I have:

...
export default defineConfig({
  server: {
    hmr: false,
  },

Also in my NodeJS server.js file I have:

const vite = await createViteServer({
  server: { middlewareMode: 'ssr', hmr: false },
})

How can I turn off Vite's hmr?

like image 319
now_world Avatar asked Dec 04 '25 15:12

now_world


1 Answers

Just modify the server property in vite.config.ts:

server: {
    hmr: false
}

(This seems to be the simplest way.)

Credit: https://stackoverflow.com/a/77129725/152711

like image 67
Freewalker Avatar answered Dec 07 '25 15:12

Freewalker