美文网首页
Error: optimization.minimizer()

Error: optimization.minimizer()

作者: 承诺一时的华丽 | 来源:发表于2022-04-14 11:37 被阅读0次
    config.optimization
                        .minimizer([
                          /!* new UglifyJsPlugin({
                                                  uglifyOptions: {
                                                      // 移除 console
                                                      // 其它优化选项 https://segmentfault.com/a/1190000010874406
                                                      compress: {
                                                          warnings: false,
                                                          drop_console: true,
                                                          drop_debugger: true,
                                                          pure_funcs: ['console.log']
                                                      }
                                                  }
                                              }) *!/
                          new TerserPlugin({
                            terserOptions: {
                              compress: {
                                warnings: false,
                                drop_console: true,
                                drop_debugger: true
                              }
                            }
                          }),
                          // 配置compression-webpack-plugin压缩
                          new CompressionWebpackPlugin({
                            algorithm: 'gzip',
                            test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
                            threshold: 10240,
                            minRatio: 0.8
                          })
                        ])
    
    • 修改为
    config.optimization.minimizer('js')
                        .use(new TerserPlugin({
                            terserOptions: {
                                compress: {
                                    warnings: false,
                                    drop_console: true,
                                    drop_debugger: true
                                }
                            }
                        })).use(new CompressionWebpackPlugin({
                            algorithm: 'gzip',
                            test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
                            threshold: 10240,
                            minRatio: 0.8
                        })
                    );
    

    相关文章

      网友评论

          本文标题:Error: optimization.minimizer()

          本文链接:https://www.haomeiwen.com/subject/qbdtertx.html