For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/packages/rspeedy/interfaces/ChunkSplitCustom.md.
Lynx
  • 简体中文
  • 接口: ChunkSplitCustom

    Performance.chunkSplit 用于配置 chunk 拆分策略。

    已被弃用

    请使用顶层的 Config.splitChunks 选项代替。

    属性

    splitChunks?

    optional splitChunks?: false | OptimizationSplitChunksOptions

    可以指定自定义的 Rspack chunk 拆分配置。

    默认值

    undefined

    示例

    • 将 @lynx-js/react 和 react-router 拆分到 lib-react chunk 中。
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        chunkSplit: {
          strategy: 'custom',
          splitChunks: {
            cacheGroups: {
              react: {
                test: /node_modules[\\/](@lynx-js[\\/]react|react-router)[\\/]/,
                name: 'lib-react',
              },
            },
          },
        },
      },
    })

    strategy

    strategy: "custom"

    chunk 拆分策略。

    备注

    • split-by-experience(Rsbuild 默认):根据经验制定的拆分策略,自动将一些常用的 npm 包拆分为体积适中的 chunk。

    • split-by-module:按 NPM 包的粒度拆分,每个 NPM 包对应一个 chunk。

    • split-by-size:根据模块大小自动拆分。

    • all-in-one:将所有代码打包到一个 chunk 中。

    • single-vendor:将所有 NPM 包打包到单个 chunk 中。

    • custom:自定义 chunk 拆分策略。

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。