How to enable hot reloading via shared folders with Vagrant VM?

眉间皱痕 提交于 2020-01-04 03:55:52

问题


I have a very basic react/redux app utilizing hot reloading (i.e. when I save a change to my source code, it updates the contents of my app accordingly in browser, preserving the state of my app) via webpack. This works on myhost machine.

However, if I use a vagrant-based workflow with synced folders (so that I can use my preferred non-terminal text editor) and I make and save a change to my source code on my host machine, the hot reloading is not triggered. However, if I make/save the change on the guest machine (just using nano for simplicity), the hot reloading does trigger.

To clarify, the saved change from the host machine is reflected in the file in the guest machine, but it doesn't trigger hot reloading. If I change helloworld to Hello, World! on my host machine, the guest machine's copy of that file will also say Hello, World!, but until I also save that change on the guest machine, hot reloading will not trigger.


回答1:


This issue could be caused by Virtualbox's own file system for shared folder.

According to https://github.com/webpack/webpack-dev-server/issues/155, you could probably try this:

webpack-dev-server --watch-poll

Additionally, I believe using rsync will always work (but this will slightly change your workflow):

Webpack dev server reload doesn't work on virtual box



来源:https://stackoverflow.com/questions/34937294/how-to-enable-hot-reloading-via-shared-folders-with-vagrant-vm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!