Webpacker: Webpacker watching files changed on docker does not work

Created on 28 Nov 2017  路  8Comments  路  Source: rails/webpacker

Hello,
We found an issue using webpacker on Docker (MacOS as host machine).
The hot reloading feature does not work properly in Docker container so we need to change the development.js for activating the polling feature.
```...
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 300,
poll: 500
},
...

It would be useful to have to possibility to configure from the webpacker.yml file these options.
Could be as it:
```...
watchOptions: devServer.watchOptions 
...

And if no defined in webpacker.yml, set to
... watchOptions: { ignored: /node_modules/ } ...

Thanks,

Most helpful comment

Hello @pipopotamasu
Thanks for your answer!
I don't use valgrant with Docker, i use the default macOS virtualization solution Hyperkit.

@jshimazu
As a patch before having a good and stable solution, you can patch the development.js file in your node_modules/webpacker/ folder:
Change the watchOptions field with this:

watchOptions: {
        ignored: /node_modules/,
        aggregateTimeout: 300,
        poll: 500
      }

Hope this help you during waiting a webpacker modification

All 8 comments

@ptaillard
Hi, ptaillard !

I have also encontered a similar issue.
Do you use Vagarant on MacOS?
If it is yes, try vagrant-notify-forwarder.

I have same trouble in webpacker v3.0.2.
But not happened this issue when I use webpacker 1.x.
I also want to get solution.

environment:

Mac OS 10.13
Docker for mac 17.09.0
Rails 5.14
ruby 2.4.2
Node.js 8.9.1

Hello @pipopotamasu
Thanks for your answer!
I don't use valgrant with Docker, i use the default macOS virtualization solution Hyperkit.

@jshimazu
As a patch before having a good and stable solution, you can patch the development.js file in your node_modules/webpacker/ folder:
Change the watchOptions field with this:

watchOptions: {
        ignored: /node_modules/,
        aggregateTimeout: 300,
        poll: 500
      }

Hope this help you during waiting a webpacker modification

@ptaillard
Thanks for your kindness!! :)

I use docker for development environment, I have same problem.
watchOptions: { ignored: /node_modules/, aggregateTimeout: 300, poll: 500 }
did not solve my problem.
I will try to solve with this https://github.com/rails/webpacker/issues/978

I was stuck on this today. The config from @ptaillard https://github.com/rails/webpacker/issues/1045#issuecomment-348708465 solves, but manually modifying 3rd party node packages is less than ideal and won't work with my project's CI process.

One can instead make changes to config/webpack/development.js:

-module.exports = environment.toWebpackConfig()
+const devConfig = environment.toWebpackConfig();
+devConfig.devServer.watchOptions = {
+  ignored: /node_modules/,
+  aggregateTimeout: 300,
+  poll: 500,
+};
+module.exports = devConfig;

I would prefer to pass webpack-dev-server command line args (e.g.; --watch-aggregate-timeout and --watch-poll). Webpacker _does_ pass these along! I think the root cause is in webpack-dev-server not coalescing watchOptions from CLI and config, so I opened https://github.com/webpack/webpack-dev-server/issues/1220.

If you are using latest master, we have added this option to webpacker.yml. We will be releasing a new version soon

@gauravtiwari Awesome!
Thanks for adding this new options.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

naps62 picture naps62  路  3Comments

ytbryan picture ytbryan  路  3Comments

towry picture towry  路  3Comments

pioz picture pioz  路  3Comments

johan-smits picture johan-smits  路  3Comments