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.
newwebpack.optimize.LimitChunkCountPlugin({// Options...});
The following options are supported:
number
Limit the maximum number of chunks using a value greater than or equal to1
. Using1
will prevent any additional chunks from being added as the entry/main chunk is also included in the count.
webpack.config.js
const webpack=require('webpack');module.exports={// ... plugins:[newwebpack.optimize.LimitChunkCountPlugin({ maxChunks:5,}),],};
Keeping chunk size above the specified limit is no longer a feature of this plugin. UseMinChunkSizePlugin instead.
This plugin and it's options can also be invoked via theCLI:
webpack --optimize-max-chunks15