From 0e81a4d45d7e46e14672c534670b1e514cebaad8 Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Tue, 28 Nov 2017 08:45:57 +0530 Subject: [PATCH] Switch to uglifyjs-webpack-plugin --- README.md | 2 +- docs/commands.md | 2 +- template/build/webpack.prod.conf.js | 10 ++++++---- template/package.json | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fcd1d46306..476c8224a2 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ The development server will run on port 8080 by default. If that port is already - Source maps - `npm run build`: Production ready build. - - JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2). + - JavaScript minified with [UglifyJS v3](https://github.com/mishoo/UglifyJS2/tree/harmony). - HTML minified with [html-minifier](https://github.com/kangax/html-minifier). - CSS across all components extracted into a single file and minified with [cssnano](https://github.com/ben-eb/cssnano). - Static assets compiled with version hashes for efficient long-term caching, and an auto-generated production `index.html` with proper URLs to these generated assets. diff --git a/docs/commands.md b/docs/commands.md index 29aa12c76e..9d456fff92 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -16,7 +16,7 @@ All build commands are executed via [NPM Scripts](https://docs.npmjs.com/misc/sc > Build assets for production. See [Integrating with Backend Framework](backend.md) for more details. -- JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2). +- JavaScript minified with [UglifyJS v3](https://github.com/mishoo/UglifyJS2/tree/harmony). - HTML minified with [html-minifier](https://github.com/kangax/html-minifier). - CSS across all components extracted into a single file and minified with [cssnano](https://github.com/ben-eb/cssnano). - All static assets compiled with version hashes for efficient long-term caching, and a production `index.html` is auto-generated with proper URLs to these generated assets. diff --git a/template/build/webpack.prod.conf.js b/template/build/webpack.prod.conf.js index b8df87e647..28ec050124 100644 --- a/template/build/webpack.prod.conf.js +++ b/template/build/webpack.prod.conf.js @@ -9,6 +9,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') const ExtractTextPlugin = require('extract-text-webpack-plugin') const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') +const UglifyJsPlugin = require('uglifyjs-webpack-plugin') const env = {{#if_or unit e2e}}process.env.NODE_ENV === 'testing' ? require('../config/test.env') @@ -33,10 +34,11 @@ const webpackConfig = merge(baseWebpackConfig, { new webpack.DefinePlugin({ 'process.env': env }), - // UglifyJs do not support ES6+, you can also use babel-minify for better treeshaking: https://github.com/babel/minify - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false + new UglifyJsPlugin({ + uglifyOptions: { + compress: { + warnings: false + } }, sourceMap: config.build.productionSourceMap, parallel: true diff --git a/template/package.json b/template/package.json index e36ce1dcd5..d79c8a0c0c 100644 --- a/template/package.json +++ b/template/package.json @@ -107,6 +107,7 @@ "optimize-css-assets-webpack-plugin": "^3.2.0", "ora": "^1.2.0", "rimraf": "^2.6.0", + "uglifyjs-webpack-plugin": "^1.1.1", "url-loader": "^0.5.8", "vue-loader": "^13.3.0", "vue-style-loader": "^3.0.1",