forked from Canadian-Geospatial-Platform/geoview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
45 lines (42 loc) · 1.53 KB
/
webpack.prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* eslint-disable @typescript-eslint/no-var-requires */
// All lines below (3-8) needs the eslint escape no-var-requires.
// It is a file for the buid and constant, they are reuse later in the file. It is the reason why we keep it global...
const TerserPlugin = require('terser-webpack-plugin');
const { merge } = require('webpack-merge');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { WebpackBundleSizeAnalyzerPlugin } = require('webpack-bundle-size-analyzer');
const CompressionPlugin = require('compression-webpack-plugin');
const zlib = require('zlib');
const common = require('./webpack.common');
const config = {
mode: 'production',
devtool: 'source-map',
optimization: {
minimize: true,
minimizer: [new TerserPlugin({ extractComments: false })],
},
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: true,
reportFilename: '../analysis/bundle-analyzer.html',
}),
new WebpackBundleSizeAnalyzerPlugin('../analysis/bundle-size-analyzer.log'),
// compress file for our production build
// js file build for gh-page use the pre built gZip compression from GitHub
new CompressionPlugin({
filename: '[path][base].br',
algorithm: 'brotliCompress',
test: /\.(js|css|html|svg)$/,
compressionOptions: {
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]: 11,
},
},
threshold: 10240,
minRatio: 0.8,
deleteOriginalAssets: false,
}),
],
};
module.exports = merge(common, config);