Skip to content

Commit

Permalink
Add uglifyjs plugin (#2070)
Browse files Browse the repository at this point in the history
* Add uglifyjs plugin and replace -p flag with --env.production
* Add uglifyjs plugin
* Configure UglifyJsPlugin to drop console and prevent eslint error
* Turn off no-console rule because uglifyjs plugin drops it in prod
  • Loading branch information
jasonbaciulis authored and QWp6t committed Jun 16, 2018
1 parent 093b5a6 commit fd2a94f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
]
},
"rules": {
"no-console": process.env.NODE_ENV === 'production' ? 2 : 0,
"no-console": 0,
"comma-dangle": [
"error",
{
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"scripts": {
"build": "webpack --progress --config resources/assets/build/webpack.config.js",
"build:production": "webpack --progress -p --config resources/assets/build/webpack.config.js",
"build:production": "webpack --env.production --progress --config resources/assets/build/webpack.config.js",
"build:profile": "webpack --progress --profile --json --config resources/assets/build/webpack.config.js",
"start": "webpack --hide-modules --watch --config resources/assets/build/webpack.config.js",
"rmdist": "rimraf dist",
Expand Down Expand Up @@ -94,6 +94,7 @@
"stylelint": "^8.4.0",
"stylelint-config-standard": "~18.2.0",
"stylelint-webpack-plugin": "^0.10.1",
"uglifyjs-webpack-plugin": "^1.2.5",
"url-loader": "^0.6.2",
"webpack": "~3.10.0",
"webpack-assets-manifest": "^1.0.0",
Expand Down
10 changes: 10 additions & 0 deletions resources/assets/build/webpack.config.optimize.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const { default: ImageminPlugin } = require('imagemin-webpack-plugin');
const imageminMozjpeg = require('imagemin-mozjpeg');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

const config = require('./config');

Expand All @@ -21,5 +22,14 @@ module.exports = {
plugins: [imageminMozjpeg({ quality: 75 })],
disable: (config.enabled.watcher),
}),
new UglifyJsPlugin({
uglifyOptions: {
ecma: 8,
compress: {
warnings: true,
drop_console: true,
},
},
}),
],
};
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7914,7 +7914,7 @@ uglifyjs-webpack-plugin@^0.4.6:
uglify-js "^2.8.29"
webpack-sources "^1.0.1"

uglifyjs-webpack-plugin@^1.2.4:
uglifyjs-webpack-plugin@^1.2.4, uglifyjs-webpack-plugin@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.5.tgz#2ef8387c8f1a903ec5e44fa36f9f3cbdcea67641"
dependencies:
Expand Down

0 comments on commit fd2a94f

Please sign in to comment.