Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js压缩工具的改变,Remove UglifyJs, use TeserPlugin #4

Open
xiaohesong opened this issue Mar 8, 2019 · 2 comments
Open

js压缩工具的改变,Remove UglifyJs, use TeserPlugin #4

xiaohesong opened this issue Mar 8, 2019 · 2 comments

Comments

@xiaohesong
Copy link
Owner

tester webpack plugin

uglifyjs-webpack-plugin

至于为什么切换到tester webpack plugin,可以看看维护人员的说法:

Terser vs. UglifyJS - Dramatic Improvements

并且作者也提出推荐使用tester webpack plugin, 并且在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,
})
@amazecc
Copy link

amazecc commented Apr 14, 2019

请教一下楼主,我使用这个插件的时候,会生成一个 2.2.4023f4be.js 的文件,在html中,并没有加载这个 js 导致显示不出页面,你有遇到这个问题吗,我的配置和你的差不多,只是少了一个 compress.ecma

@xiaohesong
Copy link
Owner Author

@amazecc 没有碰到过耶,你这个js也有可能是懒加载的js。报错是关于这个js文件404吗? 不知道你的报错是啥。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants