> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# Interface: Performance

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

## Properties

### buildCache?

> `optional` **buildCache?**: `boolean` | [`BuildCache`](/next/api/packages/rspeedy/interfaces/BuildCache.md)

**`Beta`**

Enable or configure persistent build cache.

#### Default Value

```ts
false
```

#### Remarks

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

#### Examples

Enable persistent build cache.

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

export default defineConfig({
  performance: {
    buildCache: true,
  },
})
```

Customize build cache.

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

export default defineConfig({
  performance: {
    buildCache: {
      cacheDigest: [process.env.SOME_ENV],
      buildDependencies: ['postcss.config.js'],
    },
  },
})
```

***

### ~~chunkSplit?~~

> `optional` **chunkSplit?**: [`ChunkSplit`](/next/api/packages/rspeedy/interfaces/ChunkSplit.md) | [`ChunkSplitBySize`](/next/api/packages/rspeedy/interfaces/ChunkSplitBySize.md) | [`ChunkSplitCustom`](/next/api/packages/rspeedy/interfaces/ChunkSplitCustom.md)

[Performance.chunkSplit](#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](/next/api/packages/rspeedy/interfaces/Config.md#splitchunks) option instead.

***

### printFileSize?

> `optional` **printFileSize?**: `boolean` | `PrintFileSizeOptions`

Whether to print the file sizes after production build.

#### Default Value

```ts
true
```

#### Remarks

See [Rsbuild - performance.printFileSize](https://rsbuild.rs/config/performance/print-file-size) for details.

#### Examples

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

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

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

Set total to false to disable total size output.

```ts
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:

```ts
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:

```ts
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:

```ts
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:

```ts
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.

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

export default defineConfig({
  performance: { profile: true },
})
```

***

### removeConsole?

> `optional` **removeConsole?**: `boolean` | [`ConsoleType`](/next/api/packages/rspeedy/type-aliases/ConsoleType.md)\[]

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

#### Default Value

```ts
false
```

#### Examples

- Remove all `console` methods

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

export default defineConfig({
  performance: {
    removeConsole: true,
  },
})
```

- Remove specific `console` methods

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

export default defineConfig({
  performance: {
    removeConsole: ['log', 'warn']
  },
})
```
