close
logologo
Guide
Config
Plugin
API
Community
Version
Changelog
Rsbuild 0.x Doc
English
简体中文
Guide
Config
Plugin
API
Community
Changelog
Rsbuild 0.x Doc
English
简体中文
logologo
Overview
root
mode
plugins
logLevel
environments

dev

dev.assetPrefix
dev.browserLogs
dev.cliShortcuts
dev.client
dev.hmr
dev.lazyCompilation
dev.liveReload
dev.progressBar
dev.setupMiddlewares
dev.watchFiles
dev.writeToDisk

resolve

resolve.aliasStrategy
resolve.alias
resolve.conditionNames
resolve.dedupe
resolve.extensions
resolve.mainFields

source

source.assetsInclude
source.decorators
source.define
source.entry
source.exclude
source.include
source.preEntry
source.transformImport
source.tsconfigPath

output

output.assetPrefix
output.charset
output.cleanDistPath
output.copy
output.cssModules
output.dataUriLimit
output.distPath
output.emitAssets
output.emitCss
output.externals
output.filenameHash
output.filename
output.injectStyles
output.inlineScripts
output.inlineStyles
output.legalComments
output.manifest
output.minify
output.module
output.overrideBrowserslist
output.polyfill
output.sourceMap
output.target

html

html.appIcon
html.crossorigin
html.favicon
html.inject
html.meta
html.mountId
html.outputStructure
html.scriptLoading
html.tags
html.templateParameters
html.template
html.title

server

server.base
server.compress
server.cors
server.headers
server.historyApiFallback
server.host
server.htmlFallback
server.https
server.middlewareMode
server.open
server.port
server.printUrls
server.proxy
server.publicDir
server.strictPort

security

security.nonce
security.sri

tools

tools.bundlerChain
tools.cssExtract
tools.cssLoader
tools.htmlPlugin
tools.lightningcssLoader
tools.postcss
tools.rspack
tools.styleLoader
tools.swc

performance

performance.buildCache
performance.bundleAnalyze
performance.chunkSplit
performance.dnsPrefetch
performance.preconnect
performance.prefetch
performance.preload
performance.printFileSize
performance.profile
performance.removeConsole
performance.removeMomentLocale

moduleFederation

moduleFederation.options
📝 Edit this page on GitHub
Previous Pagetools.swc
Next Pageperformance.bundleAnalyze

#performance.buildCache

  • Type:
type BuildCacheConfig =
  | boolean
  | {
      cacheDirectory?: string;
      cacheDigest?: Array<string | undefined>;
      buildDependencies?: string[];
    };
  • 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.

TIP

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:

rsbuild.config.ts
export default {
  performance: {
    buildCache: true,
  },
};

Or only enable cache in development mode:

rsbuild.config.ts
const isDev = process.env.NODE_ENV === 'development';

export default {
  performance: {
    buildCache: isDev,
  },
};

#Options

#cacheDirectory

  • Type: string
  • Default: node_modules/.cache

Set the output directory of the cache files.

rsbuild.config.ts
import path from 'node:path';

export default {
  performance: {
    buildCache: {
      cacheDirectory: path.resolve(__dirname, 'node_modules/.my-cache'),
    },
  },
};

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

rsbuild.config.ts
export default defineConfig({
  performance: {
    buildCache: {
      cacheDigest: [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.json
  • tsconfig.json
  • .env, .env.*
  • .browserslistrc
  • tailwindcss.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.

rsbuild.config.ts
export default {
  performance: {
    buildCache: {
      buildDependencies: [__filename],
    },
  },
};