* 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
36 lines
894 B
JavaScript
36 lines
894 B
JavaScript
'use strict'; // eslint-disable-line
|
|
|
|
const { default: ImageminPlugin } = require('imagemin-webpack-plugin');
|
|
const imageminMozjpeg = require('imagemin-mozjpeg');
|
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
|
|
|
const config = require('./config');
|
|
|
|
module.exports = {
|
|
plugins: [
|
|
new ImageminPlugin({
|
|
optipng: { optimizationLevel: 7 },
|
|
gifsicle: { optimizationLevel: 3 },
|
|
pngquant: { quality: '65-90', speed: 4 },
|
|
svgo: {
|
|
plugins: [
|
|
{ removeUnknownsAndDefaults: false },
|
|
{ cleanupIDs: false },
|
|
{ removeViewBox: false },
|
|
],
|
|
},
|
|
plugins: [imageminMozjpeg({ quality: 75 })],
|
|
disable: (config.enabled.watcher),
|
|
}),
|
|
new UglifyJsPlugin({
|
|
uglifyOptions: {
|
|
ecma: 8,
|
|
compress: {
|
|
warnings: true,
|
|
drop_console: true,
|
|
},
|
|
},
|
|
}),
|
|
],
|
|
};
|