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

Getting Started

Introduction
Quick start
Features
Glossary

Framework

React
Vue
Preact
Svelte
Solid

Basic

CLI
Dev server
Output files
Static assets
HTML
JSON
Wasm
TypeScript
Web Workers
Deploy static site
Upgrade Rsbuild

Configuration

Configure Rspack
Configure Rsbuild
Configure SWC

Styling

CSS
CSS Modules
CSS-in-JS
Tailwind CSS v4
Tailwind CSS v3
UnoCSS

Advanced

Path aliases
Environment variables
Hot module replacement
Browserslist
Browser compatibility
Module Federation
Multi-environment builds
Server-side rendering (SSR)
Testing

Optimization

Code splitting
Bundle size optimization
Improve build performance
Inline static assets

Migration

Migrating from Rsbuild 0.x
webpack
Create React App
Vue CLI
Vite
Vite plugin
Modern.js Builder

Debug

Debug mode
Build profiling
Use Rsdoctor

FAQ

General FAQ
Features FAQ
Exceptions FAQ
HMR FAQ
📝 Edit this page on GitHub
Previous PageBundle size optimization
Next PageInline static assets

#Improve build performance

Rsbuild optimizes build performance by default, but you may encounter performance issues as your project grows larger.

This document provides optional optimization methods to improve build performance.

#Performance profiling

Performance profiling helps identify bottlenecks in your project, enabling targeted optimization.

Please refer to the Build Performance Analysis section.

#General optimization

These general optimization methods can speed up both development and production builds.

#Upgrade Rsbuild

Upgrading to the latest version of Rsbuild provides the latest performance optimizations. See Upgrade Rsbuild for more details.

#Enable persistent cache

Rsbuild provides performance.buildCache configuration to significantly improve rebuild speed.

#Reduce module count

Optimizing the number of modules referenced by the application reduces bundle size and improves build performance. Read the Bundle Size Optimization section to learn optimization methods.

#Optimize Tailwind CSS

When using Tailwind CSS v3, incorrectly configuring the content field in tailwind.config.js can lead to poor build and HMR performance.

Refer to Tailwind CSS v3 - Optimize build performance for more details.

#Parallel Less compilation

If your project uses the @rsbuild/plugin-less plugin with a large number of Less files, you can try enabling parallel compilation to improve build performance.

Refer to Less Plugin - parallel for more details.

#Tool selection

While Rsbuild delivers excellent build performance out of the box, certain JavaScript-based tools can negatively impact performance, particularly in large projects.

  • @rsbuild/plugin-babel: This plugin is based on Babel. We recommend using the more performant SWC for code transformation instead.
  • @rsbuild/plugin-less: The Less compiler has relatively poor performance. Consider using @rsbuild/plugin-sass or other performant CSS solutions as alternatives.
  • terser-webpack-plugin: You can replace Terser with faster minimizers, such as Rsbuild's built-in SWC minifier.

#Development optimization

These methods improve performance in development mode.

#Enable lazy compilation

Enabling lazy compilation can significantly reduce the number of modules compiled at dev startup and improve startup time.

rsbuild.config.ts
export default {
  dev: {
    lazyCompilation: true,
  },
};

Refer to dev.lazyCompilation for more information.

#Enable native watcher

Enabling Rspack's native watcher can improve HMR performance in development mode.

rsbuild.config.ts
export default {
  tools: {
    rspack: {
      experiments: {
        nativeWatcher: true,
      },
    },
  },
};

#Source map format

To provide a good debugging experience, Rsbuild uses the cheap-module-source-map format in development mode by default. This is a high-quality source map format with some performance overhead.

You can improve build speed by adjusting the source map format through output.sourceMap.

For example, to disable source maps:

rsbuild.config.ts
export default {
  output: {
    sourceMap: {
      js: false,
    },
  },
};

Or set the source map format to the fastest eval format in development mode:

rsbuild.config.ts
export default {
  output: {
    sourceMap: {
      js: process.env.NODE_ENV === 'development' ? 'eval' : false,
    },
  },
};

For detailed differences between different source map formats, see Rspack - devtool.

#Browserslist for development

This strategy is similar to "Adjust Browserslist". The difference is that we can set different browserslist configurations for development and production, thereby reducing compilation overhead in development.

For example, you can add the following config to .browserslistrc to target only the latest browsers in development while supporting a broader range in production:

.browserslistrc
[production]
chrome >= 87
edge >= 88
firefox >= 78
safari >= 14

[development]
last 1 chrome version
last 1 firefox version
last 1 safari version

Note that this can lead to differences in build output between development and production modes.