
Rspack Best Practices
This is a configuration and optimization guide for Rspack, the Rust-powered bundler that's becoming a faster alternative to webpack. It covers the essentials: setting up rspack.config.ts with defineConfig, choosing between built-in CSS handling versus legacy loaders for webpack migrations, and profiling bottlenecks with RSPACK_PROFILE or Node's cpu-prof flag. The real value is in the opinionated choices, like preferring Rspack's built-in plugins over JavaScript alternatives and keeping rule conditions explicit. Use this when you're starting a new Rspack project, migrating from webpack, or troubleshooting slow builds. The guidance on asset modules versus legacy loaders and the security note about not publishing source maps are especially practical.
- skills.sh installs
- 689
- GitHub stars
- 98
- last updated
- Aug 21, 2026
Install
$ npx -y skills add rstackjs/agent-skills --skill rspack-best-practices --agent claude-codeInstalls into .claude/skills of the current project.
Files
Rspack best practices
Apply these rules when writing or reviewing Rspack projects.
Configuration
- Use
rspack.config.tsanddefineConfig - Define explicit
entryvalues for multi-page applications - Keep one main config and branch by
process.env.NODE_ENVonly when needed - Keep rule conditions narrow and explicit (
test,include,exclude,resourceQuery) - Prefer built-in Rspack plugins/loaders over community JS alternatives when equivalent features exist
CLI
If @rspack/cli is installed:
- Use
rspack devfor local development - Use
rspack buildfor production build - Use
rspack previewonly for local production preview
Type checking
- Use
ts-checker-rspack-pluginfor integrated dev/build type checks - Or run
tsc --noEmit/vue-tsc --noEmitas an explicit script step
CSS
Choose one strategy:
- Built-in CSS (
type: 'css' | 'css/auto' | 'css/module') for modern setups css-loader+CssExtractRspackPluginfor webpack migration compatibilitystyle-loaderfor pure style-in-JS runtime injection scenarios
Optional:
Sponsors
Details
- Repository
- github.com/rstackjs/agent-skills
- Categories
- Frontend Development, Documentation, AI & Agent Building, Debugging, Automation & Workflows, CLI & Terminal
- First seen
- Jun 3, 2026