vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 680 forks source link

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

Open amoshydra opened 6 years ago

amoshydra commented 6 years ago

This change will automatically allow webpack to minify ES6 code.

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

amoshydra commented 6 years ago

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 commented 6 years ago

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,
}