-
Notifications
You must be signed in to change notification settings - Fork 42
/
webpack.prod.ts
48 lines (45 loc) · 1.36 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
// utils
const commonWebpack = require('./webpack.common.ts')
const mergeWebpack = require('webpack-merge').merge
const commonPath = require('path')
// Plugins
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const TerserJSPlugin = require('terser-webpack-plugin')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const DIRECTORY_STATIC = require('./src/utils/env').STATIC_DIRECTORY
module.exports = mergeWebpack(commonWebpack, {
mode: 'production',
devtool: 'source-map',
output: {
filename: `${DIRECTORY_STATIC}[contenthash:10].js`,
chunkFilename: pathData => {
return ['interceptor', 'setup-interceptor'].includes(pathData.chunk.name)
? '[contenthash:10].js'
: `${DIRECTORY_STATIC}[contenthash:10].js`
},
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre', // this forces this rule to run first.
use: ['source-map-loader'],
include: [
commonPath.resolve(__dirname, 'node_modules/@influxdata/giraffe'),
commonPath.resolve(__dirname, 'node_modules/@influxdata/clockface'),
],
},
],
},
optimization: {
emitOnErrors: false,
minimize: true,
minimizer: [
new TerserJSPlugin({
parallel: 2,
}),
new CssMinimizerPlugin(),
],
},
plugins: [new ForkTsCheckerWebpackPlugin()],
})