Create-react-app: Allow user to set WebpackDevServer watchOptions.poll option for react-scripts start

Created on 16 Nov 2016  路  9Comments  路  Source: facebook/create-react-app

This could potentially be done by modifying the instantiation of the WebpackDevServer in start.js to look like:

...
watchOptions: {
  ignored: /node_modules/,
  poll: process.env.REACT_APP_POLL || undefined,
}
...

This use case is important to me (and others) because I'm developing in a Docker container, which has issues with inotify (due to mounting volumes with aufs), which precludes the automatic rebuild without the watchOptions poll setting.

underlying tools

Most helpful comment

Chokidar, which Webpack uses for watching changes has an environment to force the use of polling: CHOKIDAR_USEPOLLING. Does this fix the issue with Docker?

CHOKIDAR_USEPOLLING=true npm start

All 9 comments

We try to avoid config flags like this as much as possible. I wonder if it would be possible to somehow detect that we're in an environment like that and fall back to polling automatically.

Same for me, I cannot count on inotify since I am using shared folders, vagrant and Virtualbox but I'd like to use polling as a workaround.

Chokidar, which Webpack uses for watching changes has an environment to force the use of polling: CHOKIDAR_USEPOLLING. Does this fix the issue with Docker?

CHOKIDAR_USEPOLLING=true npm start

Using the env variable works for me.
There does not seem to be an env variable to set the interval though, correct?

It seems that an env variable for polling interval has been requested (https://github.com/paulmillr/chokidar/issues/518) and the author has approved the idea, someone just needs to implement it 馃槂

Going to close as there is a path forward (described above) that is out of our control.

Thanks @fson updating script to use CHOKIDAR_USEPOLLING=true react-scripts start helped. Maybe would be nice to put this to react-create-app docs - or just add there reference to webpack docs... what do you guys think? As for many it might be quite an issue to solve watchmode...

Hey, I might be being docker-stupid, but where is this supposed to code? I assumed that you would replace the command but that seems not to be the case?

you know, if all these nodejs people writing cli apps used nconf.env().argv() we'd be able to set configuration through environment variables or command line arguments.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaveLindberg picture DaveLindberg  路  3Comments

adrice727 picture adrice727  路  3Comments

barcher picture barcher  路  3Comments

stopachka picture stopachka  路  3Comments

alleroux picture alleroux  路  3Comments