Archived
0
0
Fork 0
This repository has been archived on 2024-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
website/webpack.prod.js
2021-07-12 22:03:28 -07:00

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",
},
});