In Docker container on Windows, it cannot rebuild when files changed, so I need poll files to know whether they are changed. It is similar to webpack watch's option "poll".
refrence: https://webpack.js.org/configuration/watch/#watchoptions-poll
Just like webpack, I can config a param named "poll",which is a millisecond.
Now there is no option.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 0.0.1
| Node | 8.9.3
| npm/Yarn | 5.5.1
| Operating System | windows 10
Can we automatically detect the need to poll somehow? I would prefer not adding a million options if we can choose the right default automatically.
Without getting pretty deep into the weeds, it may be hard to detect the conditions where you would need to use polling. The problem is that inotify WILL work, but it will only see local changes. So for example, if you exec into the container and touch a file, it will catch it, but if you change it externally nothing will happen.
The best solution I can imagine would be UNIX specific and would basically consist of the following:
cifs
, nfs
, vboxsf
will all have trouble with inotify.This may actually be worth an option though...
It is possible to set polling for chokidar via environment variables. I am in a similiar situation where I need to work on a windows machine with a docker development setup.
An example for setting polling via docker-compose.yml:
version: '2'
services:
web:
build: .
command: yarn start
ports:
- "1234:1234"
- "49359:49359"
volumes:
- .:/code
environment:
- CHOKIDAR_USEPOLLING=1
see chokidar docs
It is also possible to set the polling interval CHOKIDAR_INTERVAL=1
@marcklei - that's a great find, thanks for sharing! Parcel also supports dotenv
if you'd rather define the environment variable alongside you project as opposed to your machine configuration.
Wow, I looked at the Chokidar source code and 100% missed this even though I was looking for it. Thanks for the tip, this is hugely useful for me!
Closing in favor of using CHOKIDAR_USEPOLLING=1 which seems favorable to the flag anyways since it can be set in a config file.
@brandon93s even with CHOKIDAR_USEPOLLING though, hot reloading does not work. Does anyone have any solution to that?
@brandon93s even with CHOKIDAR_USEPOLLING though, hot reloading does not work. Does anyone have any solution to that?
Maybe this can work for you.
Most helpful comment
It is possible to set polling for chokidar via environment variables. I am in a similiar situation where I need to work on a windows machine with a docker development setup.
An example for setting polling via docker-compose.yml:
see chokidar docs
It is also possible to set the polling interval
CHOKIDAR_INTERVAL=1