2018-03-13 07:19:30 -04:00
|
|
|
const merge = require('webpack-merge')
|
2019-11-28 05:20:22 -05:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin')
|
|
|
|
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2018-03-13 07:19:30 -04:00
|
|
|
|
|
|
|
const base = require('./webpack.config')
|
|
|
|
|
2020-01-29 05:25:33 -05:00
|
|
|
// Use "smart" merge: attempts to combine loaders targeting the same file type,
|
|
|
|
// overriding the base config
|
2020-03-31 05:12:46 -04:00
|
|
|
module.exports = merge.smart(
|
|
|
|
base,
|
|
|
|
{
|
|
|
|
mode: 'production',
|
2019-08-06 08:20:02 -04:00
|
|
|
|
2020-03-31 05:12:46 -04:00
|
|
|
// Enable a full source map. Generates a comment linking to the source map
|
2020-04-08 04:35:01 -04:00
|
|
|
devtool: 'hidden-source-map',
|
2018-03-13 07:19:30 -04:00
|
|
|
|
2020-03-31 05:12:46 -04:00
|
|
|
output: {
|
|
|
|
// Override filename to include hash for immutable caching
|
2021-04-27 03:52:58 -04:00
|
|
|
filename: 'js/[name]-[chunkhash].js',
|
2020-03-31 05:12:46 -04:00
|
|
|
},
|
2019-11-28 05:20:22 -05:00
|
|
|
|
2020-03-31 05:12:46 -04:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
// Override base font loading to add hash to filename so that we can
|
|
|
|
// use "immutable" caching
|
|
|
|
test: /\.(woff|woff2)$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
outputPath: 'fonts',
|
|
|
|
publicPath: '/fonts/',
|
2021-12-10 05:02:13 -05:00
|
|
|
name: '[name]-[hash]-1.[ext]',
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-03-31 05:12:46 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
optimization: {
|
|
|
|
// Minify JS (with Terser) and CSS (with cssnano)
|
2021-02-09 10:39:13 -05:00
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
terserOptions: {
|
2022-03-18 06:13:02 -04:00
|
|
|
keep_classnames: /(Error|Exception)$/,
|
|
|
|
keep_fnames: /(Error|Exception)$/,
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2021-02-09 10:39:13 -05:00
|
|
|
}),
|
2021-04-27 03:52:58 -04:00
|
|
|
new OptimizeCssAssetsPlugin(),
|
|
|
|
],
|
2020-03-31 05:12:46 -04: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
|
2021-04-27 03:52:58 -04:00
|
|
|
filename: 'stylesheets/[name]-[chunkhash].css',
|
|
|
|
}),
|
|
|
|
],
|
2020-01-29 05:25:33 -05:00
|
|
|
},
|
2020-07-02 11:51:38 -04:00
|
|
|
{}
|
2020-03-31 05:12:46 -04:00
|
|
|
)
|