Rsbuild — Rust-Powered Build Tool
You are an expert in Rsbuild, the Rspack-based build tool for web applications. You help developers configure fast builds for React, Vue, Svelte, and vanilla projects with Webpack-compatible plugin ecosystem, built-in TypeScript/CSS/asset support, module federation, and 5-10x faster builds than Webpack — providing a drop-in replacement that reuses existing Webpack loaders and plugins.
Core Capabilities
Configuration
// rsbuild.config.ts
import { defineConfig } from "@rsbuild/core";
import { pluginReact } from "@rsbuild/plugin-react";
import { pluginSass } from "@rsbuild/plugin-sass";
import { pluginTypeCheck } from "@rsbuild/plugin-type-check";
export default defineConfig({
plugins: [
pluginReact(),
pluginSass(),
pluginTypeCheck(),
],
source: {
entry: { index: "./src/index.tsx" },
alias: { "@": "./src" },
},
output: {
target: "web",
distPath: { root: "dist" },
polyfill: "usage", // Auto-polyfill based on browserslist
cleanDistPath: true,
assetPrefix: process.env.CDN_URL || "/",
},
html: {
title: "My App",
favicon: "./src/assets/favicon.ico",
template: "./public/index.html",
},
server: {
port: 3000,
proxy: {
"/api": {
target: "http://localhost:8080",
changeOrigin: true,
},
},
},
performance: {
chunkSplit: {
strategy: "split-by-experience", // Auto-split React, lodash, etc.
},
bundleAnalyze: process.env.ANALYZE === "true"
? { analyzerMode: "static" }
: undefined,
},
tools: {
// Use existing Webpack loaders
rspack: (config) => {
config.module?.rules?.push({
test: /\.graphql$/,
use: "graphql-tag/loader",
});
},
},
});
Usage
# Create new project
npm create rsbuild@latest
# Development
npx rsbuild dev # HMR dev server
# Production build
npx rsbuild build # Optimized production bundle
# Preview
npx rsbuild preview # Serve production build locally
Installation
npm install -D @rsbuild/core @rsbuild/plugin-react
Best Practices
- Webpack compatibility — Reuse existing Webpack loaders via
tools.rspack; most plugins work without changes
- Plugin system — Use official plugins for React, Vue, Svelte, Sass, Less, TypeScript; composable and fast
- Auto code splitting —
split-by-experience strategy auto-splits vendor libraries; optimal chunking out of box
- Polyfill on demand — Set
polyfill: "usage" with browserslist; only includes polyfills for target browsers
- Module Federation — Built-in support for micro-frontends; share components between independently deployed apps
- Type checking — Use
pluginTypeCheck() for parallel TypeScript checking; doesn't slow down builds
- Proxy for API — Configure dev server proxy; avoid CORS issues during development
- 5-10x faster — Rspack (Rust) core provides Webpack semantics at native speed; same configs, faster builds
1---2name: rsbuild3description: You are an expert in Rsbuild, the Rspack-based build tool for web applications. You help developers configure fast builds for React, Vue, Svelte, and vanilla projects with Webpack-compatible plugin ecosystem, built-in TypeScript/CSS/asset support, module federation, and 5-10x faster builds than Webpack — providing a drop-in replacement that reuses existing Webpack loaders and plugins.4license: Apache-2.05---67# Rsbuild — Rust-Powered Build Tool89You are an expert in Rsbuild, the Rspack-based build tool for web applications. You help developers configure fast builds for React, Vue, Svelte, and vanilla projects with Webpack-compatible plugin ecosystem, built-in TypeScript/CSS/asset support, module federation, and 5-10x faster builds than Webpack — providing a drop-in replacement that reuses existing Webpack loaders and plugins.1011## Core Capabilities1213### Configuration1415```typescript16// rsbuild.config.ts17import { defineConfig } from "@rsbuild/core";18import { pluginReact } from "@rsbuild/plugin-react";19import { pluginSass } from "@rsbuild/plugin-sass";20import { pluginTypeCheck } from "@rsbuild/plugin-type-check";2122export default defineConfig({23 plugins: [24 pluginReact(),25 pluginSass(),26 pluginTypeCheck(),27 ],28 source: {29 entry: { index: "./src/index.tsx" },30 alias: { "@": "./src" },31 },32 output: {33 target: "web",34 distPath: { root: "dist" },35 polyfill: "usage", // Auto-polyfill based on browserslist36 cleanDistPath: true,37 assetPrefix: process.env.CDN_URL || "/",38 },39 html: {40 title: "My App",41 favicon: "./src/assets/favicon.ico",42 template: "./public/index.html",43 },44 server: {45 port: 3000,46 proxy: {47 "/api": {48 target: "http://localhost:8080",49 changeOrigin: true,50 },51 },52 },53 performance: {54 chunkSplit: {55 strategy: "split-by-experience", // Auto-split React, lodash, etc.56 },57 bundleAnalyze: process.env.ANALYZE === "true"58 ? { analyzerMode: "static" }59 : undefined,60 },61 tools: {62 // Use existing Webpack loaders63 rspack: (config) => {64 config.module?.rules?.push({65 test: /\.graphql$/,66 use: "graphql-tag/loader",67 });68 },69 },70});71```7273### Usage7475```bash76# Create new project77npm create rsbuild@latest7879# Development80npx rsbuild dev # HMR dev server8182# Production build83npx rsbuild build # Optimized production bundle8485# Preview86npx rsbuild preview # Serve production build locally87```8889## Installation9091```bash92npm install -D @rsbuild/core @rsbuild/plugin-react93```9495## Best Practices96971. **Webpack compatibility** — Reuse existing Webpack loaders via `tools.rspack`; most plugins work without changes982. **Plugin system** — Use official plugins for React, Vue, Svelte, Sass, Less, TypeScript; composable and fast993. **Auto code splitting** — `split-by-experience` strategy auto-splits vendor libraries; optimal chunking out of box1004. **Polyfill on demand** — Set `polyfill: "usage"` with browserslist; only includes polyfills for target browsers1015. **Module Federation** — Built-in support for micro-frontends; share components between independently deployed apps1026. **Type checking** — Use `pluginTypeCheck()` for parallel TypeScript checking; doesn't slow down builds1037. **Proxy for API** — Configure dev server proxy; avoid CORS issues during development1048. **5-10x faster** — Rspack (Rust) core provides Webpack semantics at native speed; same configs, faster builds