1

My application requires a very extensive loading for certain functions, but vite updates the page by itself causing the loading to restart and lose all the progress already made on the page, I would like to know how to disable vite's auto reload.

vite.config.ts:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'

// https://vitejs.dev/config/

export default defineConfig({
  plugins: [react()],
  server: {
    host: true,
    port: 5173, // This is the port which we will use in docker
     // Thanks @sergiomoura for the window fix
    // add the next lines if you're using windows and hot reload doesn't work
    hmr: { overlay: false }, 
    watch: {
       usePolling: true
     }
  }
 })
1
  • If you're referring to disabling the hot reload maybe this can help. Commented Aug 28, 2023 at 13:50

1 Answer 1

7

You can disable HMR entirely by adding the following to your vite.config.ts file.

// vite 4.4.9
server: {
    hmr: false
}

You might also be interested in my other answer for forcing the browser to do a full reload on module changes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.