rstackjs avatar

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-code

Installs into .claude/skills of the current project.

Files

Rspack best practices

Apply these rules when writing or reviewing Rspack projects.

Configuration

  • Use rspack.config.ts and defineConfig
  • Define explicit entry values for multi-page applications
  • Keep one main config and branch by process.env.NODE_ENV only 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 dev for local development
  • Use rspack build for production build
  • Use rspack preview only for local production preview

Type checking

  • Use ts-checker-rspack-plugin for integrated dev/build type checks
  • Or run tsc --noEmit/vue-tsc --noEmit as an explicit script step

CSS

Choose one strategy:

  • Built-in CSS (type: 'css' | 'css/auto' | 'css/module') for modern setups
  • css-loader + CssExtractRspackPlugin for webpack migration compatibility
  • style-loader for 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

More from rstackjs/agent-skills

All 12
1jezweb avatarux-extractjezweb/claude-skillsExhaustively extract UX patterns from a reference web app. Walks every screen, captures screenshots of every state, records interaction patterns, copy verbatim,687skills.sh installs
2ruvnet avatarcost-booster-routeruvnet/rufloRoute tasks through hooks_route, partition by Agent Booster availability, and report Tier 1 bypass utilization with $0 cost684skills.sh installs
3ruvnet avatarintelligence-transferruvnet/rufloPublish or fetch learned patterns across projects via IPFS (Pinata) -- the cross-project pattern transfer that hooks_transfer enables684skills.sh installs
4mohitmishra786 avatarebpfmohitmishra786/low-level-dev-skillseBPF skill for Linux observability and networking. Use when writing eBPF programs with libbpf or bpftrace, attaching kprobes/tracepoints/XDP hooks, debugging ve672skills.sh installs
5product-on-purpose avatartool-design-sprint-decide-and-storyboardproduct-on-purpose/pm-skillsDay 3 (Wednesday) move of a Design Sprint that runs the art museum layout, heat map, speed critique, straw poll, Decider supervote, rumble-vs-all-in-one decisio666skills.sh installs
6aj-geddes avatarimage-optimizationaj-geddes/useful-ai-promptsOptimize images for web to reduce file size without sacrificing quality. Use compression, modern formats, and responsive techniques for faster loading.662skills.sh installs