Skip to content

Commit 7ac66d1

Browse files
EugeneHlushkomontogeek
authored andcommitted
docs(plugins) refactor LimitChunkCountPlugin page (#2654)
1 parent adae6e3 commit 7ac66d1

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

src/content/plugins/limit-chunk-count-plugin.md

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ contributors:
55
- skipjack
66
- tbroadley
77
- byzyk
8+
- EugeneHlushko
89
---
910

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.
1112

1213
``` js
1314
new webpack.optimize.LimitChunkCountPlugin({
@@ -20,29 +21,57 @@ new webpack.optimize.LimitChunkCountPlugin({
2021

2122
The following options are supported:
2223

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`
2525

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`
2727

28-
``` js
29-
new webpack.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+
const webpack = require('webpack');
34+
module.exports = {
35+
// ...
36+
plugins: [
37+
new webpack.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+
const webpack = require('webpack');
54+
module.exports = {
55+
// ...
56+
plugins: [
57+
new webpack.optimize.LimitChunkCountPlugin({
58+
minChunkSize: 1000
59+
})
60+
]
61+
};
3362
```
3463

3564

36-
## CLI
65+
## Usage via CLI
3766

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/):
3968

40-
``` bash
41-
--optimize-max-chunks 15
69+
```bash
70+
webpack --optimize-max-chunks 15
4271
```
4372

4473
or
4574

46-
``` bash
47-
--optimize-min-chunk-size 10000
75+
```bash
76+
webpack --optimize-min-chunk-size 10000
4877
```

0 commit comments

Comments
 (0)