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

# Interface: BuildCache

**`Beta`**

启用或配置持久化构建缓存。

## Remarks

该功能目前为实验性功能，未来可能会发生变化。

## Properties

### buildDependencies?

> `optional` **buildDependencies?**: `string`\[]

**`Beta`**

包含构建依赖的文件数组。
Rspack 会使用其中每个文件的 hash 来使持久化缓存失效。

#### Default Value

`['package.json', 'tsconfig.json' (or source.tsconfigPath), '.env', '.env.*', 'tailwindcss.config.*']`；使用 Rspeedy CLI 且启用了 `performance.buildCache` 时，还会添加当前加载的 `lynx.config.*` 文件。

#### Example

将 `postcss.config.js` 添加到构建依赖中。

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

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

***

### cacheDigest?

> `optional` **cacheDigest?**: (`string` | `undefined`)\[]

**`Beta`**

添加额外的缓存摘要，当数组中的任意值发生变化时，之前的构建缓存将会失效。

#### Default Value

```ts
undefined
```

#### Example

将 `process.env.SOME_ENV` 添加到缓存摘要中。

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

export default defineConfig({
  performance: {
    buildCache: {
      cacheDigest: [process.env.SOME_ENV],
    },
  },
})
```

***

### cacheDirectory?

> `optional` **cacheDirectory?**: `string`

**`Beta`**

缓存文件的输出目录。

#### Default Value

```ts
'node_modules/.cache'
```
