Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot Module Reload not working Windows Docker + wsl #1153

Closed
johdougss opened this issue Nov 26, 2020 · 3 comments · Fixed by #841
Closed

Hot Module Reload not working Windows Docker + wsl #1153

johdougss opened this issue Nov 26, 2020 · 3 comments · Fixed by #841

Comments

@johdougss
Copy link

johdougss commented Nov 26, 2020

Describe the bug

I use windows docker(19.03.13) + wsl 2 (Ubuntu 20.04).
On windows, changes to files are not captured and hmr does not work.

the solution is to add a configuration to the chokidar
usePolling: true

const watcher = chokidar.watch(root, {

const watcher = chokidar.watch(root, {
    ignored: ['**/node_modules/**', '**/.git/**'],
    // #610
    awaitWriteFinish: {
      stabilityThreshold: 100,
      pollInterval: 10
    },
    usePolling: true
  }) as HMRWatcher

would it be possible to add an option to the command?
vite --use-polling

System Info

  • vite version: 1.0.0-rc.13
  • Operating System: Windows
  • Node version: v15.3.0
  • yarn version 1.22.5
  • Installed vue version from yarn.lock
  • Installed @vue/compiler-sfc version 3.0.2
@underfin underfin linked a pull request Nov 27, 2020 that will close this issue
@underfin
Copy link
Member

You can resolve this by add vite.config.js.

export default { 
   chokidarWatchOptions: {
    usePolling: true
  }
}

@rubenhazelaar
Copy link

Passing options to chokidar this way is not yet possible in 1.0.0-rc.13 and 2.0.0.-alpha.2 breaks (it's alpha so understandable). Can we expect this behavior to be implemented in 1.x.x?

@TheKLARKEN
Copy link

Passing usePolling to the server.watch options in the Vite config worked for me on Docker WSL2:

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    watch: {
      usePolling: true
    }
  }
})

I found this out by exploring the latest Vite server config docs. This workaround is required simply because of the way WSL currently works with the Windows filesystem. If you move your files into the Linux filesystem, you won't have this problem and possibly save yourself from a couple others--but that isn't my favorite way of doing things. 😄

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants