performance.buildCache
- Type:
- Default:
false - Version:
>= 1.2.5
To enable or configure persistent build cache.
When enabled, Rspack will store the build snapshots in the cache directory. In subsequent builds, if the cache is hit, Rspack can reuse the cached results instead of rebuilding from scratch, which can reduce the build time.
Rspack's persistent cache is experimental and may change in the future.
Enable cache
Setting performance.buildCache to true will enable the persistent build cache:
Or only enable cache in development mode:
Options
cacheDirectory
- Type:
string - Default:
node_modules/.cache
Set the output directory of the cache files.
cacheDigest
- Type:
Array<string | undefined> - Default:
undefined
Add additional cache digests, the previous build cache will be invalidated when any value in the array changes.
cacheDigest allows you to add variables that affect the build result, for example process.env.SOME_ENV.
buildDependencies
- Type:
string[]
buildDependencies is an array of additional code dependencies for the build. Rspack will use a hash of each of these items and all dependencies to invalidate the filesystem cache.
Equivalent to Rspack's cache.buildDependencies option.
Default value
Rsbuild will use the following configuration files as the default build dependencies:
package.jsontsconfig.json.env,.env.*.browserslistrctailwindcss.config.*
Additionally:
- When using Rsbuild CLI, it will also automatically add the Rsbuild configuration file (
rsbuild.config.*) to the build dependencies. - When using Rsbuild's loadConfig JS API, it will also automatically add the configuration file path to the build dependencies.
Example
When you add other build dependencies, Rsbuild merges these custom dependencies with the default dependencies and passes them to Rspack.

