Webpack 热更新 CSS 引起的栈溢出(out of me

2018-09-07  本文已影响0人  般犀

发现使用 webpack 热更新 CSS 多次后会引起内存溢出导致 webpack 退出。



搞了半天时间找原因,最后终于发现是什么在捣鬼。

网上找资料发现 webpack issues/6929# 对这个问题有详细的讨论,列了几个可能的原因:

针对第一种情况,已经在 postcss-loader 2.6.1 被修复,请检查自己的 postcss-loader 版本;
第二种情况没有找到解决方法 emmmm
第三种我看我的 hot-update.json hash每次都是固定的,所以应该不是这个问题,如果是因为这个问题,可以参考Removal of *.hot-update.json files 给 hot-update.json 一个固定的命名。

但是当我把解决措施应用在我的 webpack 的时候,发现并不能解决我的问题,此时,我发现我的 bebel 有一个 warning:

[BABEL] Note: The code generator has deoptimised the styling of D:\recharge-exchange-gift-singalDay\node_modules\react-dom\cjs\react-dom.development.js as it exceeds the max of 500KB.
bebel 对库里的 react-dom 做了处理,推测可能是因为这个原因,参考了# What does “The code generator has deoptimised the styling of [some file] as it exceeds the max of ”100KB“” mean?
中 Marcus Junius Brutus 的答案,在 处理 js 的 rules 中把 node_modules 排除掉了。
警告没了,但是问题依然存在。
无奈只好对比同事的 webpack 跑跑看,发现原来是在 development 阶段就使用了 es3ify-webpack-plugin 这个将代码转为 es3 的插件,在 development 阶段把插件排除掉,问题解决了~
上一篇 下一篇

猜你喜欢

热点阅读