Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amoshydra
Copy link

@amoshydra amoshydra commented Feb 27, 2018

This change will automatically allow webpack to minify ES6 code.

Related to #505

@amoshydra
Copy link
Author

amoshydra commented Feb 27, 2018

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
Copy link
Author

amoshydra commented Feb 27, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant