Webpack UglifyJS仍在发出警告信息

时间:2016-05-15 20:08:38

标签: javascript webpack aurelia uglifyjs

A lot of warnings with webpack uglify

我已经关闭了UglifyJS中的警告,但我仍然从webpack收到一些警告。

WARNING in main-0.2.8.js from UglifyJs
Dropping unused variable e [./~/bluebird/js/browser/bluebird.js:29,292]
Dropping unused variable o [./~/bluebird/js/browser/bluebird.js:29,292]
Dropping unused variable i [./~/bluebird/js/browser/bluebird.js:29,292]
Non-strict equality against boolean: == false [./~/aurelia-pal-browser/dist/commonjs/aurelia-pal-browser.js:200,0]
Non-strict equality against boolean: == false [./~/aurelia-pal-browser/dist/commonjs/aurelia-pal-browser.js:208,0]

来自webpack.config的插件

  plugins: [
    new AureliaWebpackPlugin(),
    new HtmlWebpackPlugin({
      title: 'Aurelia webpack skeleton - ' + pkg.version,
      template: 'index.prod.html',
      filename: 'index.html'
    }),
    new ProvidePlugin({
      $: 'jquery',
      jquery: 'jquery',
      "windows.jquery": 'jquery'
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    })
  ]

如果有人知道如何摆脱最后几个很好的警告。

1 个答案:

答案 0 :(得分:3)

当您通过UglifyJs最小化时,它会警告您删除了未使用的变量,并将false!1中的true值更改为!0。这不是问题,只是减少文件长度。另见Javascript minification why is false replaced with !1 and true with !0。 但是,您可以尝试指定压缩选项以删除这些警告:

    compress: {
        warnings: false,
        booleans: false,
        unused: false
    }

有关详细信息,请参阅https://github.com/mishoo/UglifyJS2#compressor-options。我希望它有所帮助。