Open xiaohesong opened 5 years ago
tester webpack plugin
uglifyjs-webpack-plugin
至于为什么切换到tester webpack plugin,可以看看维护人员的说法:
Terser vs. UglifyJS - Dramatic Improvements。
并且作者也提出推荐使用tester webpack plugin, 并且在webpack5中会默认使用这个。
webpack5
下面是我在项目中的用法:
const TerserPlugin = require('terser-webpack-plugin'); //... new TerserPlugin({ terserOptions: { parse: { ecma: 8, }, compress: { ecma: 5, warnings: false, comparisons: false, inline: 2, }, mangle: { safari10: true, }, output: { ecma: 5, comments: false, ascii_only: true, }, }, parallel: true, // Enable file caching cache: true, sourceMap: false, })
请教一下楼主,我使用这个插件的时候,会生成一个 2.2.4023f4be.js 的文件,在html中,并没有加载这个 js 导致显示不出页面,你有遇到这个问题吗,我的配置和你的差不多,只是少了一个 compress.ecma
@amazecc 没有碰到过耶,你这个js也有可能是懒加载的js。报错是关于这个js文件404吗? 不知道你的报错是啥。
tester webpack plugin
uglifyjs-webpack-plugin
至于为什么切换到
tester webpack plugin
,可以看看维护人员的说法:Terser vs. UglifyJS - Dramatic Improvements。
并且作者也提出推荐使用
tester webpack plugin
, 并且在webpack5
中会默认使用这个。下面是我在项目中的用法: