forked from Netcentric/fe-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimization.config.js
More file actions
36 lines (34 loc) · 1.07 KB
/
optimization.config.js
File metadata and controls
36 lines (34 loc) · 1.07 KB
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
const path = require('path')
const { isProduction, excludedFromVendors } = require('./general.config');
const checkChunk = require('../utils/checkChunk');
const nodeModules = `node_modules`;
// curry to pass the module to check
const test = ( excludes, includes) => (mod) => checkChunk(mod.context, excludes, includes);
module.exports = {
minimize: isProduction,
usedExports: 'global',
runtimeChunk: {
name: 'commons/treeshaking.bundle.js'
},
splitChunks: {
chunks: 'initial',
minChunks: 2,
cacheGroups: {
// Treeshake vendors in node_modules (but keep unique vendors at the clientlibs it belongs)
vendors: {
test: test([nodeModules], excludedFromVendors),
minChunks: 2,
enforce : true,
name: 'commons/vendors.bundle.js',
// used on at least 2 modules
},
// Treeshakes common imports, if used in more than 2 clientlibs
treeshaking: {
test: test([nodeModules]),
minChunks: 2,
enforce : true,
name: 'commons/treeshaking.bundle.js',
}
}
}
};