Home > @lynx-js/rspeedy > Performance > printFileSize

Performance.printFileSize property

Whether to print the file sizes after production build.

Performance.printFileSize

See Rsbuild - performance.printFileSize for details.

Signature:

printFileSize?: PerformanceConfig['printFileSize'] | undefined;

Example 1

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
  },
})

Example 2

Set total to false to disable total size output.

import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
  performance: {
    printFileSize: {
      total: false,
    },
  },
})

Example 3

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,
    },
  },
})

Example 4

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,
    },
  },
})

Example 5

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,
    }
  },
})

Example 6

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),
    }
  },
})
除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。