Browser Does Not Update on Save with webpack-dev-server in Docker in WSL 2

543 views Asked by At

I have looked at various solutions to no avail.

Testing webpack-dev-server on WSL 2 works fine; when I update the src/main.js file the browser updates however when inside of a docker container again running within WSL 2, the browser does not automatically update on saving changes, however the content does update when I manually refresh the browser?

Docker container ran via

sudo docker run -ti --name justatest -p 3009:8080 -v /home/dev/webpacktest:/home/test node:12 /bin/bash

webpack.dev.config

const path = require("path");

module.exports = {
 mode: "development",
 entry: {
  main: ["./src/main.js"],
 },
 output: {
  filename: "[name].bundle.js",
  path: path.resolve(__dirname, "./dist"),
 },
 devServer: {
  contentBase: "./dist",
  host: "0.0.0.0",
  port: "8080",
 },
};

package.json

{
 "name": "webpacktest",
 "version": "1.0.0",
 "scripts": {
    "dev": "webpack-dev-server --config webpack.dev.js --hot --port 8080 --host 0.0.0.0"
 },
 "license": "MIT",
 "devDependencies": {
  "webpack": "^4.44.2",
  "webpack-cli": "^3.3.12",
  "webpack-dev-server": "^3.11.0"
 }
}

Also when I run a create-react-app inside a docker container inside of WSL 2 the browser refreshes on change. How does create-react-app do it

1

There are 1 answers

0
succeed On BEST ANSWER

Rebooted computer and all was fine :/