Using docker containers in Windows(host) for react and webpack so that workspace has linux like feel. To do so mounting the workspace directory in container, so coding is done in atom on Windows while server is running in docker. But issue is that changes done in host folder files are not reflected and not reloaded by webpack, so created a small trick to reload changes by webpack.
Include above 2 files in project, and install the required dependencies by these files.
fileWatcherLocal.js
will listen the change on Windows and same it'll notify to the fileWatcherServer.js
server.
fileWatcherServer.js
listen the changed file path sent by fileWatcherLocal.js
and executes chmod
command to notify webpack.
fileWatcherLocal.js
must be run in host (my case Windows).
fileWatcherServer.js
must be run in docker container (I'm using forever module to run this as a daemon).
Order in which these should be run, otherwise it'll be a recursion of calls.
- Run webpack in container.
- Run
fileWatcherLocal.js
in host . - Run
fileWatcherServer.js
in container.