rsbuild-best-practices
rstackjs/agent-skills
Configure, review, and optimize Rsbuild applications with build, dev, and bundle best practices.
What is rsbuild-best-practices?
A reference guide for Rsbuild configuration, CLI usage, type checking, and bundle optimization. Use this when setting up, reviewing, or troubleshooting Rsbuild projects to ensure proper build setup, asset management, and performance.
- Configure Rsbuild with rsbuild.config.ts and defineConfig patterns
- Manage dev/build/preview CLI commands and inspect final configs
- Integrate type checking via @rsbuild/plugin-type-check or tsc/vue-tsc
- Optimize bundle size with dynamic imports and lightweight dependencies
- Handle asset imports from source directories and public URL references
- Debug config resolution and profiling with DEBUG and RSPACK_PROFILE flags
How to install rsbuild-best-practices
npx skills add https://github.com/rstackjs/agent-skills --skill rsbuild-best-practicesHow to use rsbuild-best-practices
- 1.Review the configuration section to ensure rsbuild.config.ts uses defineConfig and appropriate options
- 2.Run `rsbuild inspect` to verify final Rsbuild/Rspack configuration matches expectations
- 3.Set up type checking using @rsbuild/plugin-type-check or add tsc/vue-tsc as a script step
- 4.Apply bundle optimization: use dynamic import() for non-critical code and prefer lightweight libraries
- 5.Verify asset imports come from source directories, not public; reference public files by absolute URL
- 6.When debugging, run with DEBUG=rsbuild or use RSPACK_PROFILE=OVERVIEW for compiler bottleneck analysis
Use cases
- Setting up a new Rsbuild project with proper TypeScript and multi-page configuration
- Reviewing existing Rsbuild configs to align with best practices
- Troubleshooting slow builds or large bundles using profiling and inspection tools
- Integrating type checking into dev and production workflows
- Migrating from Rsbuild v1 to v2 using updated documentation
- Frontend engineers building with Rsbuild
- DevOps/build engineers optimizing Rsbuild pipelines
- Teams reviewing Rsbuild project configurations
- Developers troubleshooting build performance or bundle size
rsbuild-best-practices FAQ
Use tools.rspack or tools.bundlerChain only when no first-class Rsbuild option exists for your configuration need.
Run `rsbuild inspect` to view the generated Rsbuild/Rspack configs, or read files in dist/.rsbuild instead of assuming config.
Use `rsbuild build` for production builds; use `rsbuild preview` only for local testing of production output.
No; do not publish .map files to public servers/CDNs when production source maps are enabled, as they expose source code.
For v2, read http://rsbuild.rs/llms.txt; for v1, read http://v1.rsbuild.rs/llms.txt.
Full instructions (SKILL.md)
Source of truth, from rstackjs/agent-skills.
name: rsbuild-best-practices description: Configure, review, or troubleshoot Rsbuild applications, including build/dev commands, assets, type checking, and bundle optimization.
Rsbuild best practices
Apply these rules when writing or reviewing Rsbuild projects.
Configuration
- Use
rsbuild.config.tsanddefineConfig - Use
tools.rspackortools.bundlerChainonly when no first-class Rsbuild option exists - Define explicit
source.entryvalues for multi-page applications - In TypeScript projects, prefer
tsconfig.jsonpath aliases first
CLI
- Use
rsbuildfor local development - Use
rsbuild buildfor production build - Use
rsbuild previewonly for local production preview - Use
rsbuild inspectto inspect final Rsbuild/Rspack configs
Type checking
- Use
@rsbuild/plugin-type-checkfor integrated dev/build type checks - Or run
tsc --noEmit/vue-tsc --noEmitas an explicit script step
Bundle size optimization
- Prefer dynamic
import()for non-critical code paths - Prefer lightweight libraries where possible
- Keep browserslist aligned with real compatibility requirements
Asset management
- Import source-managed assets from project source directories, not from
public - Reference
publicfiles by absolute URL path
Security
- Do not publish
.mapfiles to public servers/CDNs when production source maps are enabled
Debugging
- Run with
DEBUG=rsbuildwhen diagnosing config resolution or plugin behavior - Read generated files in
dist/.rsbuildto confirm final config, not assumed config
Profiling
- Use Node CPU profiling (
--cpu-prof) when JavaScript-side overhead is suspected - Use
RSPACK_PROFILE=OVERVIEWand analyze trace output for compiler-phase bottlenecks
Documentation
- For the latest (v2) docs, read http://rsbuild.rs/llms.txt
- For Rsbuild v1 docs, read http://v1.rsbuild.rs/llms.txt
Related skills
More from rstackjs/agent-skills and the wider catalog.

rslib-best-practices
Rslib best practices for config, CLI workflow, output, declaration files, dependency handling, build optimization and toolchain integration. Use when writing, reviewing, or troubleshooting Rslib projects.

rstest-best-practices
Set up, write, and review Rstest tests with best practices for environments, mocks, snapshots, coverage, and CI.

file-manager
Agent skill from rtgs2017/nagaagent.
code-simplifier
Simplify Rust code in RTK by applying idiomatic patterns without changing behavior.
design-patterns
Rust design patterns for RTK CLI filter modules: Newtype, Builder, RAII, Trait Objects, State Machine.
rtk-tdd
Enforces Red-Green-Refactor TDD discipline for Rust with idiomatic test patterns and automated workflow.