-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.production.js
76 lines (72 loc) · 1.97 KB
/
webpack.config.production.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require('dotenv').config();
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const CopyPlugin = require('copy-webpack-plugin');
const StatsPlugin = require('stats-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const { BundleStatsWebpackPlugin } = require('bundle-stats');
const { RelativeCiAgentWebpackPlugin } = require('@relative-ci/agent');
const getCommonConfig = require('./build/webpack.config.common');
const appCommonConfig = require('./webpack.config.common');
const settings = require('./settings');
const { rootDir, distDir, publicDir } = settings;
module.exports = webpackMerge(
getCommonConfig(settings),
appCommonConfig,
{
plugins: [
new CopyPlugin([
{
from: publicDir,
to: distDir,
},
]),
new webpack.DefinePlugin({
__GA__: JSON.stringify(process.env.GA),
}),
new StatsPlugin('../artifacts/webpack.stats.json', {
context: rootDir,
assets: true,
entrypoints: true,
modules: true,
chunks: true,
performance: true,
timings: true,
children: false,
source: false,
excludeAssets: /artifacts/,
}),
new BundleStatsWebpackPlugin({
html: true,
json: true,
outDir: '../artifacts',
stats: {
excludeAssets: /artifacts/,
},
}),
new RelativeCiAgentWebpackPlugin({
stats: {
excludeAssets: /artifacts/,
},
}),
],
optimization: {
minimizer: [new TerserPlugin({ sourceMap: true })],
splitChunks: {
chunks: 'all',
name: true,
minSize: Infinity,
cacheGroups: {
vendor: {
chunks: 'initial',
name: 'vendor',
filename: 'vendor.[contenthash].js',
test: /[\\/]node_modules[\\/]/,
priority: -10,
enforce: true,
},
},
},
},
},
);