You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/plugins/limit-chunk-count-plugin.md
+44-15Lines changed: 44 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,10 @@ contributors:
5
5
- skipjack
6
6
- tbroadley
7
7
- byzyk
8
+
- EugeneHlushko
8
9
---
9
10
10
-
While writing your code, you may have already added many code split points to load stuff on demand. After compiling you might notice that some chunks are too small - creating larger HTTP overhead. Luckily, this plugin can post-process your chunks by merging them.
11
+
While writing your code, you may have already added many code split points to load stuff on demand. After compiling you might notice that some chunks are too small - creating larger HTTP overhead. `LimitChunkCountPlugin` can post-process your chunks by merging them.
11
12
12
13
```js
13
14
newwebpack.optimize.LimitChunkCountPlugin({
@@ -20,29 +21,57 @@ new webpack.optimize.LimitChunkCountPlugin({
20
21
21
22
The following options are supported:
22
23
23
-
-`maxChunks`: Limit the maximum number of chunks using a value greater than or equal to `1`. Using `1` will prevent any additional chunks from being added as the entry/main chunk is also included in the count.
24
-
-`minChunkSize`: Set a minimum chunk size.
24
+
### `maxChunks`
25
25
26
-
While merging chunks, webpack will try to identify those that have duplicate modules and merge them first. Nothing will be merged into the entry chunk, so as not to impact initial page loading time. Here's a small example:
26
+
`number`
27
27
28
-
```js
29
-
newwebpack.optimize.LimitChunkCountPlugin({
30
-
maxChunks:5, // Must be greater than or equal to one
31
-
minChunkSize:1000
32
-
});
28
+
Limit the maximum number of chunks using a value greater than or equal to `1`. Using `1` will prevent any additional chunks from being added as the entry/main chunk is also included in the count.
29
+
30
+
__webpack.config.js__
31
+
32
+
```javascript
33
+
constwebpack=require('webpack');
34
+
module.exports= {
35
+
// ...
36
+
plugins: [
37
+
newwebpack.optimize.LimitChunkCountPlugin({
38
+
maxChunks:5
39
+
})
40
+
]
41
+
};
42
+
```
43
+
44
+
### `minChunkSize`
45
+
46
+
`number`
47
+
48
+
Set a minimum chunk size in bytes.
49
+
50
+
__webpack.config.js__
51
+
52
+
```javascript
53
+
constwebpack=require('webpack');
54
+
module.exports= {
55
+
// ...
56
+
plugins: [
57
+
newwebpack.optimize.LimitChunkCountPlugin({
58
+
minChunkSize:1000
59
+
})
60
+
]
61
+
};
33
62
```
34
63
35
64
36
-
## CLI
65
+
## Usage via CLI
37
66
38
-
This plugin and it's options can also be invoked via the CLI:
67
+
This plugin and it's options can also be invoked via the [CLI](/api/cli/):
0 commit comments