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/packages/rspeedy/interfaces/Performance.md.
Lynx
  • English
  • Interface: Performance

    The Performance option is used to optimize the build-time and runtime performance.

    Properties

    buildCache?

    optional buildCache?: boolean | BuildCache

    Beta

    Enable or configure persistent build cache.

    Default Value

    false

    Remarks

    This feature is experimental and may be changed in the future.

    Examples

    Enable persistent build cache.

    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        buildCache: true,
      },
    })

    Customize build cache.

    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        buildCache: {
          cacheDigest: [process.env.SOME_ENV],
          buildDependencies: ['postcss.config.js'],
        },
      },
    })

    chunkSplit?

    optional chunkSplit?: ChunkSplit | ChunkSplitBySize | ChunkSplitCustom

    Performance.chunkSplit is used to configure the chunk splitting strategy.

    Default Value

    Unset, which bundles everything into one chunk (same as 'all-in-one').

    Deprecated

    Use the top-level Config.splitChunks option instead.


    printFileSize?

    optional printFileSize?: boolean | PrintFileSizeOptions

    Whether to print the file sizes after production build.

    Default Value

    true

    Remarks

    See Rsbuild - performance.printFileSize for details.

    Examples

    If you don't want to print any information, you can disable it by setting printFileSize to false:

    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        printFileSize: false
      },
    })

    Set total to false to disable total size output.

    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        printFileSize: {
          total: false,
        },
      },
    })

    Set detail to false to disable per-asset size output.

    If you don't need to view the size of each static asset, you can set detail to false. In this case, only the total size will be output:

    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        printFileSize: {
          detail: false,
        },
      },
    })

    If you don't need to view the gzipped size, you can set compressed to false. This can save some gzip computation time for large projects:

    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        printFileSize: {
          compressed: false,
        },
      },
    })

    To include only static assets that meet certain criteria, use a filter function with include.

    If returned false, the static asset will be excluded and not included in the total size or detailed size.

    only output static assets larger than 10kB:

    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        printFileSize: {
          include: (asset) => asset.size > 10 * 1000,
        }
      },
    })

    To exclude static assets that meet certain criteria, use a filter function with exclude. If both include and exclude are set, exclude will take precedence.

    Rspeedy defaults to excluding source map, license files, and .d.ts type files, as these files do not affect page load performance.

    exclude .html files in addition to the default:

    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        printFileSize: {
          exclude: (asset) =>
            /\.(?:map|LICENSE\.txt)$/.test(asset.name) ||
            /\.html$/.test(asset.name),
        }
      },
    })

    profile?

    optional profile?: boolean

    Whether to capture timing information in Lynx runtime integrations such as ReactLynx.

    Remarks

    A framework includes runtime information using console.profile when this is enabled.

    Default Value

    true when DEBUG=lynx, otherwise undefined

    Example

    Enable profile.

    • Frameworks like ReactLynx will include runtime information using console.profile.
    • Rspeedy will emit dist/stats.json after build for bundle analysis compatibility.
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: { profile: true },
    })

    removeConsole?

    optional removeConsole?: boolean | ConsoleType[]

    Whether to remove console.[methodName] in production build.

    Default Value

    false

    Examples

    • Remove all console methods
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        removeConsole: true,
      },
    })
    • Remove specific console methods
    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      performance: {
        removeConsole: ['log', 'warn']
      },
    })
    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.