78 lines
1.7 KiB
JavaScript
78 lines
1.7 KiB
JavaScript
const { merge } = require("webpack-merge");
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin');
|
|
const CompressionPlugin = require("compression-webpack-plugin");
|
|
const common = require('./webpack.common.js');
|
|
|
|
module.exports = merge(common, {
|
|
mode: 'production',
|
|
plugins: [
|
|
new CspHtmlWebpackPlugin({
|
|
'script-src': '',
|
|
'style-src': '',
|
|
}, {
|
|
hashingMethod: 'sha512',
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: '[name].[chunkhash].css',
|
|
}),
|
|
new CompressionPlugin({
|
|
filename: "[path][base].gz",
|
|
test: /\.(js|css|html|svg)$/,
|
|
compressionOptions: {
|
|
level: 9,
|
|
},
|
|
minRatio: Infinity,
|
|
deleteOriginalAssets: true,
|
|
}),
|
|
],
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.[cs][ac]ss$/,
|
|
exclude: /node_modules/,
|
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
|
|
},
|
|
],
|
|
},
|
|
optimization: {
|
|
splitChunks: {
|
|
cacheGroups: {
|
|
vendor: {
|
|
test: /[\\/]node_modules[\\/]/,
|
|
name: 'vendors',
|
|
chunks: 'all',
|
|
enforce: true,
|
|
},
|
|
js: {
|
|
test: /\.js$/,
|
|
name: 'js',
|
|
chunks: 'all',
|
|
enforce: true,
|
|
},
|
|
styles: {
|
|
test: /\.css$/,
|
|
name: 'styles',
|
|
chunks: 'all',
|
|
enforce: true,
|
|
},
|
|
},
|
|
},
|
|
runtimeChunk: true,
|
|
moduleIds: 'deterministic',
|
|
removeAvailableModules: true,
|
|
removeEmptyChunks: true,
|
|
usedExports: true,
|
|
innerGraph: true,
|
|
concatenateModules: true,
|
|
mergeDuplicateChunks: true,
|
|
portableRecords: true,
|
|
sideEffects: false,
|
|
flagIncludedChunks: true,
|
|
chunkIds: "deterministic",
|
|
realContentHash: true,
|
|
providedExports: true,
|
|
emitOnErrors: true,
|
|
mangleExports: "deterministic",
|
|
},
|
|
});
|