webpack-dev-server hot reload not working

前端 未结 11 1993
囚心锁ツ
囚心锁ツ 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:22

    You can try adding this to your config:

    module.exports = {
    ...
      devServer: {
        contentBase: './dist/', // Since your index.html is in the "dist" dir
        open: true,             // Automatically open the browser
        hot: true,              // Automatically refresh the page whenever bundle.js changes
                                // (You will have to refresh manually if other files change)
      },
    ...
    };
    

    And then running (no options):
    webpack-dev-server

提交回复
热议问题