blendid icon indicating copy to clipboard operation
blendid copied to clipboard

Replace webpack's uglify with new uglify plugin to allow ES6 uglification

Open amoshydra opened this issue 7 years ago • 2 comments

This change will automatically allow webpack to minify ES6 code.

Related to https://github.com/vigetlabs/blendid/issues/505

amoshydra avatar Feb 27 '18 03:02 amoshydra

Alternatively, should it provide user a way to use their own uglify plugin?

webpackConfig.plugins.push(
  new webpack.DefinePlugin(TASK_CONFIG.javascripts.production.definePlugin),
  (webpackConfig.uglifyPlugin) // Allow the use of other uglifier
    ? new webpackConfig.uglifyPlugin(uglifyConfig)
    : new webpack.optimize.UglifyJsPlugin(uglifyConfig),
  new webpack.NoEmitOnErrorsPlugin()
)

amoshydra avatar Feb 27 '18 03:02 amoshydra

Note:

This is a potential breaking change since UglifyJsPlugin require minifyOptions to be defined inside the uglifyOptions object. Ref: https://github.com/webpack-contrib/uglifyjs-webpack-plugin#uglifyoptions

Previously

uglifyConfig = {
  compress: false,
  mangle: false,
  beautify: true,
  comments: true,
  sourceMap: true,
}

Now

uglifyConfig = {
  uglifyOptions: {
    compress: false,
    mangle: false,
    output: {
      beautify: true,
      comments: true,
    },
  },
  sourceMap: true,
}

amoshydra avatar Feb 27 '18 07:02 amoshydra