Cannot run webpack-dev-server inside docker

前端 未结 3 1597
遥遥无期
遥遥无期 2021-02-01 20:46

I have created a docker image which serves a simple react app using webpack from inside the container, but I get nothing in the browser.

Here are my config files

3条回答
  •  盖世英雄少女心
    2021-02-01 21:21

    I just want to add something to Raphayol answer if you couldn't enable hot-reloading of webpack-dev-server inside container.
    I couldn't make webpack or webpack-dev-server watch (--watch) mode work even after mounting my project folder into container.
    To fix this you need to understand how webpack detects file changes within a directory.
    It uses one of 2 softwares that add OS level support for watching for file changes called inotify and fsevent. Standard Docker images usually don't have these (specially inotify for linux) preinstalled so you have to install it in your Dockerfile.
    Look for inotify-tools package in your distro's package manager and install it. fortunately all alpine, debian, centos have this.

提交回复
热议问题