Originally, chunks (and modules imported inside them) were connected by a parent-child relationship in the internal webpack graph. The Show
Since webpack v4, the DefaultsOut of the box By default it only affects on-demand chunks, because changing initial chunks would affect the script tags the HTML file should include to run the project. Webpack will automatically split chunks based on these conditions:
When trying to fulfill the last two conditions, bigger chunks are preferred. ConfigurationWebpack provides a set of options for developers that want more control over this functionality. optimization.splitChunksThis configuration object represents the default behavior of the webpack.config.js
splitChunks.automaticNameDelimiter
By default webpack will generate names using origin and name of the chunk (e.g. splitChunks.chunks
This indicates which chunks will be selected for optimization. When a string is provided, valid values are Note that it is applied to the fallback cache group as well ( webpack.config.js
Alternatively, you may provide a function for more control. The return value will indicate whether to include each chunk.
splitChunks.maxAsyncRequests
Maximum number of parallel requests when on-demand loading. splitChunks.maxInitialRequests
Maximum number of parallel requests at an entry point. splitChunks.defaultSizeTypes
Sets the size types which are used when a number is used for sizes. splitChunks.minChunks
The minimum times must a module be shared among chunks before splitting. splitChunks.hidePathInfo
Prevents exposing path info when creating names for parts splitted by maxSize. splitChunks.minSize
Minimum size, in bytes, for a chunk to be generated. splitChunks.minSizeReduction
Minimum size reduction to the main chunk (bundle), in bytes, needed for a chunk to be generated. Meaning if splitting into a chunk does not reduce the size of the main chunk (bundle) by the given amount of bytes, it won't be split, even if it meets the splitChunks.enforceSizeThreshold
|