2022-04-06 09:59:13 +00:00
|
|
|
const { merge } = require('webpack-merge')
|
2019-11-28 10:20:22 +00:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin')
|
2022-04-06 09:59:13 +00:00
|
|
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
|
2019-11-28 10:20:22 +00:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2018-03-13 11:19:30 +00:00
|
|
|
|
|
|
|
const base = require('./webpack.config')
|
|
|
|
|
2022-04-06 09:59:13 +00:00
|
|
|
module.exports = merge(
|
2020-03-31 09:12:46 +00:00
|
|
|
base,
|
|
|
|
{
|
|
|
|
mode: 'production',
|
2019-08-06 12:20:02 +00:00
|
|
|
|
2020-03-31 09:12:46 +00:00
|
|
|
// Enable a full source map. Generates a comment linking to the source map
|
2020-04-08 08:35:01 +00:00
|
|
|
devtool: 'hidden-source-map',
|
2018-03-13 11:19:30 +00:00
|
|
|
|
2020-03-31 09:12:46 +00:00
|
|
|
optimization: {
|
|
|
|
// Minify JS (with Terser) and CSS (with cssnano)
|
2021-02-09 15:39:13 +00:00
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
terserOptions: {
|
2022-03-18 10:13:02 +00:00
|
|
|
keep_classnames: /(Error|Exception)$/,
|
|
|
|
keep_fnames: /(Error|Exception)$/,
|
2021-04-27 07:52:58 +00:00
|
|
|
},
|
2021-02-09 15:39:13 +00:00
|
|
|
}),
|
2022-05-19 12:44:09 +00:00
|
|
|
new CssMinimizerPlugin({
|
|
|
|
minimizerOptions: {
|
|
|
|
// disable mergeLonghand to avoid a cssnano bug https://github.com/cssnano/cssnano/issues/864
|
|
|
|
preset: ['default', { mergeLonghand: false }],
|
|
|
|
},
|
|
|
|
}),
|
2021-04-27 07:52:58 +00:00
|
|
|
],
|
2020-03-31 09:12:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
// Extract CSS to a separate file (rather than inlining to a <style> tag)
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
// Output to public/stylesheets directory and append hash for immutable
|
|
|
|
// caching
|
2022-04-06 09:59:13 +00:00
|
|
|
filename: 'stylesheets/[name]-[contenthash].css',
|
2021-04-27 07:52:58 +00:00
|
|
|
}),
|
|
|
|
],
|
2020-01-29 10:25:33 +00:00
|
|
|
},
|
2020-07-02 15:51:38 +00:00
|
|
|
{}
|
2020-03-31 09:12:46 +00:00
|
|
|
)
|