For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/rspeedy/rspeedy.chunksplit.strategy.md.
Rspeedy logo
Rspeedy
  • English
  • Home > @lynx-js/rspeedy > ChunkSplit > strategy

    ChunkSplit.strategy property

    The ChunkSplitting strategy.

    Signature:

    strategy?: 'all-in-one' | 'split-by-module' | 'split-by-experience' | 'single-vendor' | undefined;

    Default Value

    In Rsbuild's default chunk splitting behavior, the strategy is 'split-by-experience'.

    Remarks

    • split-by-experience(Rsbuild default): an empirical splitting strategy, automatically splits some commonly used npm packages into chunks of moderate size.

    • split-by-module: split by NPM package granularity, each NPM package corresponds to a chunk.

    • split-by-size: automatically split according to module size.

    • all-in-one: bundle all codes into one chunk.

    • single-vendor: bundle all NPM packages into a single chunk.

    • custom: custom chunk splitting strategy.

    Example 1

    • Use all-in-one to put all modules in one chunk.
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        chunkSplit: {
          strategy: 'all-in-one',
        },
      },
    })

    Example 2

    • Use single-vendor to put all third-party dependencies in one chunk. And source code in another chunk.
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        chunkSplit: {
          strategy: 'single-vendor',
        },
      },
    })
    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.