Add uglifyjs plugin (#2070)
* 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
This commit is contained in:
@@ -32,7 +32,7 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
"rules": {
|
||||
"no-console": process.env.NODE_ENV === 'production' ? 2 : 0,
|
||||
"no-console": 0,
|
||||
"comma-dangle": [
|
||||
"error",
|
||||
{
|
||||
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user