FMGordillo
FMGordillo

Reputation: 81

How to handle Hot Reloading in a React app, inside Docker, inside WSL?

First of all, this is the repo that I've been talking about: Github

In my Macbook with Docker, this works just fine. But I've been trying to use WLS (Ubuntu inside Windows). I've followed up this tutorial on how to handle Docker in WLS (and also how to handle Volumes)

It works, I change the code in my host (Windows) and actually it changes inside the container (Docker inside Linux), but for some reason, the apps don't refresh.

I'm using two apps, one is a React app (with react-scripts) and other with Express (using nodemon). Both don't reload on changes.

What could be wrong?

Upvotes: 3

Views: 1746

Answers (1)

Christian Blom
Christian Blom

Reputation: 66

The part about nodemon is answered in this thread: Nodemon Doesn't Restart in Windows Docker Environment. The short answer is to start nodemon with the -L flag to enable legacy file polling.

Editing this as I found a solution to the react client issue as well. The trick is the use the environment flag - CHOKIDAR_USEPOLLING=true for your react container. I have it set in my docker-compose like this:

environment:
  - CHOKIDAR_USEPOLLING=true

Upvotes: 5

Related Questions