1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Docker上のReactでのHot Reloadがうまくいかない。

Posted at

はじめに

初めてQiitaに投稿する&見習いエンジニアです。

開発環境

Windows11
Docker
React 18.2.0
Typescript 4.9.4
react-scripts 5.0.1

Docker上にcreate-react-appを利用してReactの開発環境を作成しています。

バージョンは後日記載します。

問題

ソースを修正してもブラウザ上ですぐに反映されませんでした。
いわゆるHot Reloadがうまくいきませんでした。

Ubuntu上でDockerを用いている時には特に問題なく動くのですが、Windows11条のDockerを用いる際にはどうしてもうまくいきませんでした、

解決方法

以下の2つを併用して解決しました。

  1. create-react-appを利用しているフォルダ直下に.envファイルを作成した。
.env
CHOKIDAR_USEPOLLING=true
WATCHPACK_POLLING=true
  1. docker-compose.ymlファイルに以下を記載した。
docker-compose.yml
    environment:
      - CHOKIDAR_USEPOLLING=true
      - WATCHPACK_POLLING=true

参考文献

https://qiita.com/ape/items/a4268e991211c1e154af
https://github.com/facebook/create-react-app/issues/11879

なお

Hot Reloadはできるようになったもののソース変更してからブラウザに反映されるまでの時間がかなり長いです。。
後々解決したいとおもいます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?