在dev-server.js里面
var hotMiddleware = require('webpack-hot-middleware')(compiler) // force page reload when html-webpack-plugin template changes compiler.plugin('compilation', function (compilation) { compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { hotMiddleware.publish({ action: 'reload' }) cb() }) })已经使用热加载的代码,然后我的项目是用webstorm打开的,发现有时候会热部署,有时候不热部署了,后面发现原因,解决方案如下:
它默认保存在临时文件,把settings=>appearance=>system=>synchornization=>最后一项勾去掉,热部署替换是没问题的