How can I acheive this?
If I edit a file on the host machine, the containerized process won't pick up the change.
First I run a docker container with volumed source
docker run -v $(pwd):/app/:rw -it -p 1234:1234 node:10.3.0 /bin/bash
Get in the correct directory
cd /app/
Install global cli in the container
yarn global add parcel-bundler
Start the dev server
parcel src/index.pug
Now point my browser at localhost:1234 - the site is reached.
Edit a file on the host machine. The dev-server watch isn't working.
Notes: It works perfectly well on the host machine. And I have observed the same behaviour from webpack-dev-server
.
I get that it's more of a general problem than specific to this library. Help is appreciated.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.11.0
| Node | 10.3.0
| npm/Yarn | 1.3.2
| Operating System | Windows 10 Host. node:10.3.0 docker container
This might not work on Windows because it's running Docker containers in a VM. We do this on Linux and it works just fine. Can't speak to macOS, but I imagine it doesn't work there either.
I did wonder. Does anybody know of a work around for Windows?
From: Caleb Foust notifications@github.com
Sent: Monday, January 14, 2019 6:14:54 PM
To: parcel-bundler/parcel
Cc: kkjamie; Author
Subject: Re: [parcel-bundler/parcel] Hot reloading volumed source in docker container (#2539)
This might not work on Windows because it's running Docker containers in a VM. We do this on Linux and it works just fine. Can't speak to macOS, but I imagine it doesn't work there either.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/parcel-bundler/parcel/issues/2539#issuecomment-454105466, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFWkFlVUH1SQ0w5k4fr_SDysb9WFlmbPks5vDMkegaJpZM4Z-W2D.
With a Windows host OS at least, setting the CHOKIDAR_USEPOLLING=1
env var gets file watching working.
See https://github.com/parcel-bundler/parcel/issues/564#issuecomment-363924561
From this awesome article by Patrick Lee Scott:
...hot module reloading with Parcel happens on a random port by default, which won’t work for us, as we need to map the HMR port as well.
Modify the dev script inpackage.json
to include the option--hmr-port=1235
.
"dev": "npm run generate-imported-components && parcel app/index.html --hmr-port 1235"
,
And with that in place, let’s update the Docker file to map the ports on our local machine to the same ports on our container.
I followed it and mapped the port on the host to the same port (1235) on the container, and it worked wonderfully.
Most helpful comment
From this awesome article by Patrick Lee Scott:
I followed it and mapped the port on the host to the same port (1235) on the container, and it worked wonderfully.