webpack-dev-server hot reload not working

前端 未结 11 1952
囚心锁ツ
囚心锁ツ 2020-12-24 06:51

My file structure is:

dist
  css
    style.css
  index.html
  js
    bundle.js
src
  css
    style.css
  index.html
  js
    main.js
node_modules
webpack.con         


        
11条回答
  •  执念已碎
    2020-12-24 07:31

    Try this:

    In your package.json file, delete the line that contains "test" "echo \"Error: no test specified\" && exit 1" under the scripts object, and replace it with:

    ...
    "scripts": {
        "start": "webpack-dev-server --hot"
      },
    
    ...
    

    Then to restart your project, just use npm start.

    This worked for me when I ran into this problem.

    Edit: Can you share your package.json file?

    Try adding this to webpack.config.js as well

    devServer: {
      inline: true,
      port: 3000,
      hot: true
    },
    

提交回复
热议问题