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/build/output/filename/bundle.md.
Lynx
  • 简体中文
  • output.filename.bundle

    optional bundle?: BundleFilename

    Lynx 新增配置

    此配置由 pluginLynx 新增,不属于 Rsbuild 配置。在 rsbuild.config.ts 中,将它传给 pluginLynx({ ... })。

    bundle 文件的名称。

    默认值

    '[name].[platform].bundle'

    备注

    支持以下占位符:

    • [name]:入口名称。
    • [platform]:Rsbuild environment 的名称。
    • [contenthash]:bundle 内容的 hash。

    示例

    • 在 bundle 文件名中使用指定长度的 content hash:
    import { defineConfig } from '@rsbuild/core'
    import { pluginLynx } from '@lynx-js/rsbuild-plugin'
    
    export default defineConfig({
      plugins: [
        pluginLynx({
          output: {
            filename: {
              bundle: '[name].[contenthash:8].bundle',
            },
          },
        }),
      ],
    })
    • 使用函数分别控制主 bundle 和 lazy bundle (例如将 lazy bundle 输出到另一个目录,并附加 git commit hash):
    import { execSync } from 'node:child_process'
    
    import { defineConfig } from '@rsbuild/core'
    import { pluginLynx } from '@lynx-js/rsbuild-plugin'
    
    const gitHash = execSync('git rev-parse --short HEAD').toString().trim()
    
    export default defineConfig({
      plugins: [
        pluginLynx({
          output: {
            filename: {
              bundle: ({ lazyBundle, platform }) =>
                lazyBundle
                  ? `my-lazy-bundles/[name].[fullhash]-${gitHash}.bundle`
                  : `[name].${platform}.bundle`,
            },
          },
        }),
      ],
    })
    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。