-
-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathwebpack.config.js
54 lines (48 loc) · 1.1 KB
/
webpack.config.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
import { version as webpackVersion } from 'webpack';
import Self from '../../../src';
function recursiveIssuer(m) {
if (m.issuer) {
return recursiveIssuer(m.issuer);
}
// eslint-disable-next-line no-underscore-dangle
const chunks = webpackVersion === '4' ? m._chunks : m.getChunks();
for (const chunk of chunks) {
return chunk.name;
}
return false;
}
module.exports = {
entry: {
a: './a.js',
b: './b.js',
},
module: {
rules: [
{
test: /\.css$/,
use: [Self.loader, 'css-loader'],
},
],
},
optimization: {
splitChunks: {
cacheGroups: {
aStyles: {
name: 'styles_a',
test: (m, c, entry = 'a') =>
m.constructor.name === 'CssModule' && recursiveIssuer(m) === entry,
chunks: 'all',
enforce: true,
},
bStyles: {
name: 'styles_b',
test: (m, c, entry = 'b') =>
m.constructor.name === 'CssModule' && recursiveIssuer(m) === entry,
chunks: 'all',
enforce: true,
},
},
},
},
plugins: [new Self()],
};