Skip to content

advancedChunks

  • Type: optional advancedChunks: object

Allows you to do manual chunking. For deeper understanding, please refer to the in-depth documentation.

groups?

Groups to be used for advanced chunking.

includeDependenciesRecursively?

  • Type: optional includeDependenciesRecursively: boolean

By default, each group will also include captured modules' dependencies. This reduces the chance of generating circular chunks.

If you want to disable this behavior, it's recommended to both set

to avoid generating invalid chunks.

Default

ts
true

maxModuleSize?

  • Type: optional maxModuleSize: number

Global fallback of group.maxModuleSize, if it's not specified in the group.

maxSize?

  • Type: optional maxSize: number

Global fallback of group.maxSize, if it's not specified in the group.

minModuleSize?

  • Type: optional minModuleSize: number

Global fallback of group.minModuleSize, if it's not specified in the group.

minShareCount?

  • Type: optional minShareCount: number

Global fallback of group.minShareCount, if it's not specified in the group.

minSize?

  • Type: optional minSize: number

Global fallback of group.minSize, if it's not specified in the group.

Example

Basic vendor chunk

js
export default defineConfig({
  output: {
    advancedChunks: {
      minSize: 20000,
      groups: [
        {
          name: 'vendor',
          test: /node_modules/,
        },
      ],
    },
  },
});

Multiple chunk groups with priorities

js
export default defineConfig({
  output: {
    advancedChunks: {
      groups: [
        {
          name: 'react-vendor',
          test: /node_modules[\\/]react/,
          priority: 20,
        },
        {
          name: 'ui-vendor',
          test: /node_modules[\\/](antd%7C@mui)/,
          priority: 15,
        },
        {
          name: 'vendor',
          test: /node_modules/,
          priority: 10,
        },
        {
          name: 'common',
          minShareCount: 2,
          minSize: 10000,
          priority: 5,
        },
      ],
    },
  },
});

Size-based splitting

js
export default defineConfig({
  output: {
    advancedChunks: {
      groups: [
        {
          name: 'large-libs',
          test: /node_modules/,
          minSize: 100000, // 100KB
          maxSize: 250000, // 250KB
          priority: 10,
        },
      ],
    },
  },
});

Released under the MIT License.