2

I am trying to split my vendor chunk in a Vue JS app using Webpack 4. I have been able to get reasonable results with this setting:

config.optimization.set('splitChunks', {
      cacheGroups: {
        vendors: {
          name: 'chunk-vendors',
          test: /[\\/]node_modules[\\/]/,
          maxSize: 500000,
          minChunks: 1,
          priority: -20,
          chunks: 'all'
        },
        // default Vue JS common chunk
        common: {
          name: 'chunk-common',
          minChunks: 2,
          priority: -30,
          chunks: 'initial',
          reuseExistingChunk: true
        }
      }
    })

But I could not find anything in the documentation that explains what the number for maxSize represents. Is bytes, KB, or an arbitrary number? It's hard to "guess" what the right value might be for my application without understanding what the number means.

Also, is it the pre-minified size or the gzipped size?

Karen B
  • 331
  • 2
  • 9
  • 1
    From the link you posted: "Using maxSize ... tells webpack to try to split chunks bigger than __maxSize bytes__ into smaller parts..." – Michal Levý Feb 07 '20 at 22:04

1 Answers1

3

Here's the final answer: splitChunks.maxSize measures in bytes

https://webpack.js.org/plugins/split-chunks-plugin/#splitchunksmaxsize

"...tells webpack to try to split chunks bigger than maxSize bytes into smaller parts..."

See also splitChunks.minSize

https://webpack.js.org/plugins/split-chunks-plugin/#splitchunksminsize

"Minimum size, in bytes, for a chunk to be generated."

Karen B
  • 331
  • 2
  • 9
  • Even after defining maxSize = 244*1024 i am getting chunks larger then 244 Kib.. Any idea why its happening ? – Amit Kumar May 23 '23 at 07:01