问题
运行项目的时候,经常会有一大片错误
Could not freeze ./src/web3/address.js: Cannot read property 'hash' of undefined
HardSourceWebpackPlugin是webpack的插件,为模块提供中间缓存步骤,但是它报错了…
临时解决方案
删除 ./node_modules/.cache 后,再npm start重启项目
确实,这行得通,但是后面还会继续蹦出来,难道每次都要去手动删除再重新启动吗?
根本解决方案
看hard-source-webpack-plugin的issues:https://github.com/mzgoddard/hard-source-webpack-plugin/issues/416
webpack.config.js
new HardSourceWebpackPlugin.ExcludeModulePlugin([
{
test: /mini-css-extract-plugin[\\/]dist[\\/]loader/,
}
])
在new HardSourceWebpackPlugin()下添加上面代码即可
重启项目,问题解决