【webpack】配置热更新

第一步

  devServer: {
    contentBase: path.join(__dirname, 'dist'),
    compress: true,
    port: 9000,
    hot: true
  },

 

第二部

  plugins: [
    new HtmlWebpackPlugin(),
    new webpack.HotModuleReplacementPlugin()
  ]

 

第三部(入口文件,entry)

if (module.hot) {
  module.hot.accept()
}

 

官方介绍

posted @ 2019-07-14 10:18  前端精髓  阅读(865)  评论(0编辑  收藏  举报
在这里插入图片描述