43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
const merge = require('webpack-merge');
|
|
const common = require('./webpack.common.js');
|
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
const ImageminPlugin = require('imagemin-webpack-plugin').default;
|
|
const imageminMozjpeg = require('imagemin-mozjpeg');
|
|
const CompressionPlugin = require('compression-webpack-plugin');
|
|
|
|
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
|
|
const OfflinePlugin = require('offline-plugin');
|
|
|
|
|
|
module.exports = merge(common, {
|
|
mode: 'production',
|
|
devtool: 'source-map',
|
|
optimization: {
|
|
minimizer: [
|
|
new TerserPlugin({
|
|
test: /\.js(\?.*)?$/i,
|
|
parallel: true,
|
|
sourceMap: true,
|
|
})
|
|
]
|
|
},
|
|
plugins: [
|
|
new CompressionPlugin({
|
|
test: /\.(html|css|js)(\?.*)?$/i // only compressed html/css/js, skips compressing sourcemaps etc
|
|
}),
|
|
new ImageminPlugin({
|
|
test: /\.(jpe?g|png|gif|svg)$/i,
|
|
gifsicle: { // lossless gif compressor
|
|
optimizationLevel: 9
|
|
},
|
|
pngquant: ({ // lossy png compressor, remove for default lossless
|
|
quality: '75'
|
|
}),
|
|
plugins: [imageminMozjpeg({ // lossy jpg compressor, remove for default lossless
|
|
quality: '75'
|
|
})]
|
|
}),
|
|
new OfflinePlugin()
|
|
]
|
|
}); |