This example shows example of using the CommonsChunkPlugin for moving modules from child-chunks to the parent chunk.
The CommonsChunkPlugin is used with selectedChunks = false argument to check for common modules in the child-chunks.
Without the plugin the pages would have this chunks:
- page
- chunk: a
- chunk: a, b
- chunk: a, b, c
- chunk: a, b, c, d
Using the CommonsChunkPlugin without minChunks argument only moves modules which are shared by all children (here only module a):
- pageA: a
- chunk: b
- chunk: b, c
- chunk: b, c, d
With minChunks = 3:
- pageB: a, b
- chunk: c
- chunk: c, d
It's also possible to provide a function instead of a number for minChunks. The function is called for each module to decide if the module should be moved or not (see pageC and pageD):
- pageC: a, c, d
- chunk: b
{{page.js}}{{webpack.config.js}}{{stdout}}
{{min:stdout}}