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
|
|
|
|
filename: 'js/[name]-[chunkhash].js'
|
|
|
|
},
|
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/',
|
|
|
|
name: '[name]-[hash].[ext]'
|
|
|
|
}
|
2020-01-29 05:25:33 -05:00
|
|
|
}
|
2020-03-31 05:12:46 -04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
optimization: {
|
|
|
|
// Minify JS (with Terser) and CSS (with cssnano)
|
|
|
|
minimizer: [new TerserPlugin(), new OptimizeCssAssetsPlugin()]
|
|
|
|
},
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
)
|