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-14 12:10:07 -05:00
|
|
|
module.exports = merge(base, {
|
2019-08-06 08:20:02 -04:00
|
|
|
mode: 'production',
|
|
|
|
|
2019-10-16 06:10:54 -04:00
|
|
|
// Enable a full source map. Generates a comment linking to the source map
|
|
|
|
devtool: 'source-map',
|
2018-03-13 07:19:30 -04:00
|
|
|
|
2018-03-13 13:44:08 -04:00
|
|
|
output: {
|
2019-10-16 06:10:54 -04:00
|
|
|
// Override filename to include hash for immutable caching
|
2019-11-28 05:20:22 -05:00
|
|
|
filename: 'js/[name]-[chunkhash].js'
|
|
|
|
},
|
|
|
|
|
|
|
|
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'
|
|
|
|
})
|
|
|
|
]
|
2018-03-13 07:19:30 -04:00
|
|
|
})
|