An error was reported when using uglify in webpack:
ERROR in app.js from UglifyJs
RangeError: Maximum call stack size exceeded
Take a look at the issues on github.
https://github.com/mishoo/UglifyJS2/issues/414
This is a problem with uglify, because uglify is called recursively. When the bundle.js file is very large, it will exceed the stack range.
Solution:
- Expand the size of the stack:
node --stack_size=100000 uglifyjs
- Change the plug-in, I use this method: (this is no problem)
Use: terser-webpack-plugin
address: https://www.npmjs.com/package/terser-webpack-plugin
yarn add terser-webpack-plugin --dev
Then change webpack.config.js and add in module.exports
optimization: {
minimizer: [
new TerserJSPlugin({
cache: true, // 是否缓存
parallel: true, // 是否并行打包
sourceMap: true,
}),
],
},