Replies: 3 comments
-
volumes:
- type: bind |
Beta Was this translation helpful? Give feedback.
-
If polling works, I guess this is something related to Docker and chokidar or fsevents rather than Vite itself. In your setup, |
Beta Was this translation helpful? Give feedback.
-
This problem is related with this issue: microsoft/WSL#4739 I solved it by moving my project to WSL (Windows Subsystem for Linux) and running everything from there. I’m using React with Vite inside a Dev Container, and fast refresh is now working properly. It seems the root cause is that inotify events are not shared between the host and the container. I wrote an article on LinkedIn explaining the full process to fix it:: https://www.linkedin.com/pulse/desarrollar-en-linux-dev-containers-desde-windows-ra%C3%BAl-castilla-bravo-cjqaf |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
I have configured a setup with Vite + Docker + NPM Workspaces. Editing files within the Vite project works as expected, and fast refresh works to reflect the changes made.
However, I also have some "shared" code that is located outside of the main Vite project that I am managing with NPM workspaces. When I modify this shared code, it does not refresh in the browser. Even if I manually refresh the page, changes are never reflected.
So it's as if Vite is not watching that "shared" location. I'm not sure how to make it do that, and I've tried different settings under
build.watch
,server.watch
to do so.Curiously, if I remove Docker from the equation - so just use Vite + NPM workspaces - then the fast-refresh works as expected both within the Vite project, and outside in the "shared" location.
So it's very weird. Any ideas how to make Vite watch the "shared" code location? I feel like it must be a Vite watching issue, since fast-refresh otherwise works on Docker when working inside the project directory.
As a workaround, I can configure Vite "polling" and that seems to work OK - though obviously I would prefer the normal file-system events method to work.
Reproduction
https://github.com/asgeo1/demonstrate-vite-watching-issue
Steps to reproduce
docker compose up
in the root.As you make changes to
project1/src/App.tsx
orproject2/src/App.tsx
you should see those changes reflected in the respective browser page.However, if you make changes to
shared/src/utils.ts
, you will only see those changes reflected inproject2
. It's not working inproject1
due to some unknown issue.(it only works in
project2
due it using "polling" rather than file events)Curiously, if you repeat all of the above steps locally, i.e.
npm install
in root locally, and thencd
to each project and run withnpm run dev
- there is no issue andproject1
will update asshared/src/utils.ts
is modifiedDocker notes:
docker-compose.yml
to removename
attribute.System Info
From inside Docker container:
From the host:
Used Package Manager
npm
Logs
No response
Validations
Beta Was this translation helpful? Give feedback.
All reactions