-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathwebpack.prod.ts
54 lines (50 loc) · 1.29 KB
/
webpack.prod.ts
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
46
47
48
49
50
51
52
53
54
export {}
// utils
const common = require('./webpack.common.ts')
const merge = require('webpack-merge')
const path = require('path')
// Plugins
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const TerserJSPlugin = require('terser-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const {STATIC_DIRECTORY} = require('./src/utils/env')
module.exports = merge(common, {
mode: 'production',
devtool: 'source-map',
output: {
filename: `${STATIC_DIRECTORY}[contenthash:10].js`,
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre', // this forces this rule to run first.
use: ['source-map-loader'],
include: [
path.resolve(__dirname, 'node_modules/@influxdata/giraffe'),
path.resolve(__dirname, 'node_modules/@influxdata/clockface'),
],
},
],
},
optimization: {
minimizer: [
new TerserJSPlugin({
cache: true,
parallel: 2,
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin({}),
],
splitChunks: {
chunks: 'all',
},
},
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: 'bundle-report.html',
openAnalyzer: false,
}),
],
})