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
| const ChainedMap = require('./ChainedMap');
| const Plugin = require('./Plugin');
|
| module.exports = class extends ChainedMap {
| constructor(parent) {
| super(parent);
| this.minimizers = new ChainedMap(this);
| this.extend([
| 'concatenateModules',
| 'flagIncludedChunks',
| 'mergeDuplicateChunks',
| 'minimize',
| 'namedChunks',
| 'namedModules',
| 'nodeEnv',
| 'noEmitOnErrors',
| 'occurrenceOrder',
| 'portableRecords',
| 'providedExports',
| 'removeAvailableModules',
| 'removeEmptyChunks',
| 'runtimeChunk',
| 'sideEffects',
| 'splitChunks',
| 'usedExports',
| ]);
| }
|
| minimizer(name) {
| if (Array.isArray(name)) {
| throw new Error(
| 'optimization.minimizer() no longer supports being passed an array. ' +
| 'Either switch to the new syntax (https://github.com/neutrinojs/webpack-chain#config-optimization-minimizers-adding) or downgrade to webpack-chain 4. ' +
| 'If using Vue this likely means a Vue plugin has not yet been updated to support Vue CLI 4+.',
| );
| }
|
| return this.minimizers.getOrCompute(
| name,
| () => new Plugin(this, name, 'optimization.minimizer'),
| );
| }
|
| toConfig() {
| return this.clean(
| Object.assign(this.entries() || {}, {
| minimizer: this.minimizers.values().map((plugin) => plugin.toConfig()),
| }),
| );
| }
|
| merge(obj, omit = []) {
| if (!omit.includes('minimizer') && 'minimizer' in obj) {
| Object.keys(obj.minimizer).forEach((name) =>
| this.minimizer(name).merge(obj.minimizer[name]),
| );
| }
|
| return super.merge(obj, [...omit, 'minimizer']);
| }
| };
|
|