webpack-dev-server nfs mount file watcher

2019-06-11 15:34发布

问题:

I have the watching plugin configured, and if I edit files on my VM, it works great. However, I have an NFS share, and I edit my files on the host. The filewatcher on the VM does not pick up changes on the NFS share.

For other reasons, I do need this to be an NFS share. Is there any way that I can make this work?

The node docs state "You can still use fs.watchFile, which uses stat polling, but it is slower and less reliable."

回答1:

I fixed this problem with Ubuntu 14.04 running on Oracle VM VirtualBox on Windows 8.1 using:

  plugins: [
    new webpack.OldWatchingPlugin(),
    new webpack.HotModuleReplacementPlugin()
  ]

I think there's a decent chance this will also fix the issue with other configurations.



回答2:

Just add this options into your webpack config.

 watchOptions: {
        poll: true
 }

You have do this because of Vagrant/Virtual box filesystem mounting specifics.