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/rspeedy/rspeedy.filename.bundle.md.
Rspeedy logo
Rspeedy
  • 简体中文
  • Home > @lynx-js/rspeedy > Filename > bundle

    Filename.bundle property

    The name of the bundle files.

    Signature:

    bundle?: BundleFilename | undefined;

    Default Value

    '[name].[platform].bundle'

    Remarks

    The following placeholder is supported:

    • [name]: the name of the entry. - [contenthash]: the contenthash of the bundle. - [platform]: the environment name of the bundle.

    Example 1

    • Using content hash in bundle filename:
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      output: {
        filename: {
          bundle: '[name].[contenthash].bundle',
        },
      },
    })

    Example 2

    • Using content hash with length in bundle filename:
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      output: {
        filename: {
          bundle: '[name].[contenthash:8].bundle',
        },
      },
    })

    Example 3

    • Using a function to control the main bundle and the lazy bundles separately (e.g. emit lazy bundles into another directory with a git commit hash appended):
    import { execSync } from 'node:child_process'
    
    import { defineConfig } from '@lynx-js/rspeedy'
    
    const gitHash = execSync('git rev-parse --short HEAD').toString().trim()
    
    export default defineConfig({
      output: {
        filename: {
          bundle: ({ lazyBundle, platform }) =>
            lazyBundle
              ? `my-lazy-bundles/[name].[fullhash]-${gitHash}.bundle`
              : `[name].${platform}.bundle`,
        },
      },
    })
    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。