rspack-best-practices
Skill97 starsChanged 3 months agoMITView on GitHub
Configure, review, or troubleshoot Rspack builds, including loaders, CSS, assets, type checking, bundle optimization, and profiling.
- Reads credentials
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 2 are distinctive, and 18 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
18
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Use rspack.config.ts and defineConfig
- Very specific: line 14
Keep one main config and branch by process.env.NODE_ENV only when needed
- Very specific: line 15
Keep rule conditions narrow and explicit (test, include, exclude, resourceQuery)
- Distinctive: line 16
Prefer built-in Rspack plugins/loaders over community JS alternatives when equivalent features exist
- Very specific: line 20
If @rspack/cli is installed:
- Very specific: line 22
Use rspack dev for local development
- Very specific: line 23
Use rspack build for production build
- Very specific: line 24
Use rspack preview only for local production preview
- Very specific: line 28
Use ts-checker-rspack-plugin for integrated dev/build type checks
- Very specific: line 41
Use builtin:lightningcss-loader when goals are syntax downgrade + vendor prefixing
- Very specific: line 42
Use sass-loader/less-loader for preprocessing Sass/Less files
- Very specific: line 43
Use @tailwindcss/webpack for Tailwind CSS integration
- Very specific: line 47
Prefer dynamic import() for non-critical code paths
- Distinctive: line 48
Prefer lightweight libraries where possible
- Very specific: line 49
Keep target aligned with real compatibility requirements
- Very specific: line 53
Import source-managed assets from project source directories, not from public
- Very specific: line 55
Prefer asset modules (asset, asset/resource, asset/inline, asset/source) over legacy file-loader/url-loader/raw-loader
- Very specific: line 59
Use Node CPU profiling (--cpu-prof) when JavaScript-side overhead is suspected
- Very specific: line 60
Use RSPACK_PROFILE=OVERVIEW and analyze trace output for compiler-phase bottlenecks
- Very specific: line 65
Do not publish .map files to public servers/CDNs when production source maps are enabled
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
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:
- Use
builtin:lightningcss-loaderwhen goals are syntax downgrade + vendor prefixing - Use
sass-loader/less-loaderfor preprocessing Sass/Less files - Use
@tailwindcss/webpackfor Tailwind CSS integration
Bundle size optimization
- Prefer dynamic
import()for non-critical code paths - Prefer lightweight libraries where possible
- Keep
targetaligned with real compatibility requirements
Asset management
- Import source-managed assets from project source directories, not from
public - Reference
publicfiles by absolute URL path - Prefer asset modules (
asset,asset/resource,asset/inline,asset/source) over legacyfile-loader/url-loader/raw-loader
Profiling
- Use Node CPU profiling (
--cpu-prof) when JavaScript-side overhead is suspected - Use
RSPACK_PROFILE=OVERVIEWand analyze trace output for compiler-phase bottlenecks - Replace known slow stacks first (
babel-loader, PostCSS, terser) with Rspack built-ins when feasible
Security
- Do not publish
.mapfiles to public servers/CDNs when production source maps are enabled
Documentation
- For the latest (v2) docs, read http://rspack.rs/llms.txt
- For Rspack v1 docs, read http://v1.rspack.rs/llms.txt
In this repository31 other files it gives its agents.
- AGENTS.mdAGENTS.md
- create-draft-release-notesSkill
- mdx-to-markdownSkill
- pr-creatorSkill
- release-blog-writerSkill
- rstack-docs-writerSkill
- rstack-eco-ci-debugSkill
- rstack-repo-maintainSkill
- rstack-skill-evaluatorSkill
- migrate-to-rsbuildSkill
- migrate-to-rslibSkill
- migrate-to-rslintSkill
- migrate-to-rstestSkill
- rsbuild-best-practicesSkill
- rsbuild-v2-upgradeSkill
- rsdoctor-analysisSkill
- rsdoctor-v2-upgradeSkill
- rslib-best-practicesSkill
- rslib-modern-packageSkill
- rspack-debuggingSkill
- rspack-split-chunksSkill
- rspack-tracingSkill
- rspack-v2-upgradeSkill
- rspress-best-practicesSkill
- rspress-custom-themeSkill
- rspress-description-generatorSkill
- rspress-docs-generatorSkill
- rspress-v2-upgradeSkill
- rstest-best-practicesSkill
- rstest-debuggingSkill
- storybook-rsbuildSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

