Webpack 4忽略UglifyJsPlugin

时间:2018-08-26 06:37:45

标签: webpack

--------------------------- Eclipse --------------------------- Java was started but returned exit code=13 C:\Program Files (x86)\Java\jre1.8.0_181\bin\javaw.exe -Dosgi.requiredJavaVersion=1.8 -Dosgi.instance.area.default=@user.home/eclipse-workspace -XX:+UseG1GC -XX:+UseStringDeduplication -Dosgi.requiredJavaVersion=1.8 -Dosgi.dataAreaRequiresExplicitInit=true -Xms256m -Xmx1024m -jar C:\Users\Roland\Downloads\eclipse\\plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar -os win32 -ws win32 -arch x86_64 -showsplash C:\Users\Roland\Downloads\eclipse\\plugins\org.eclipse.epp.package.common_4.8.0.20180619-1200\splash.bmp -launcher C:\Users\Roland\Downloads\eclipse\eclipse.exe -name Eclipse --launcher.library C:\Users\Roland\Downloads\eclipse\ \plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.700.v20180518-1200\eclipse_1705.dll -startup C:\Users\Roland\Downloads\eclipse\\plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar --launcher.appendVmargs -exitdata 379c_118 -product org.eclipse.epp.package.jee.product -vm C:\Program Files (x86)\Java\jre1.8.0_181\bin\javaw.exe -vmargs -Dosgi.requiredJavaVersion=1.8 -Dosgi.instance.area.default=@user.home/eclipse-workspace -XX:+UseG1GC -XX:+UseStringDeduplication -Dosgi.requiredJavaVersion=1.8 -Dosgi.dataAreaRequiresExplicitInit=true -Xms256m -Xmx1024m -jar C:\Users\Roland\Downloads\eclipse\\plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar --------------------------- OK --------------------------- 添加到我的Webpack配置中(如here时),JavaScript确实是最小的,但是当我手动添加时,完全如here所示,输出不会被缩小

minimize: true

是的,我们正在谈论// This minifies my assets { // ... optimization: {minimize: true}, } // This ignores the minification plugin { // ... optimization: { minimizer: [new UglifyJsPlugin()], }, }

就这么简单,但是它仍然没有实现预期的功能。关于如何使用Webpack 4.17解决此问题的任何想法?

1 个答案:

答案 0 :(得分:1)

在Webpack中设置mode: none时,您还需要自己指定minimize: true,以使minimizer能够按照the Webpack source code进行工作:

    if (options.optimization.minimize) {
        for (const minimizer of options.optimization.minimizer) {
            minimizer.apply(compiler);
        }
    }