Rsbuild Best Practices

rstackjs/agent-skills/skills/rsbuild-best-practices

作者 rstackjs2966acbef746無授權條款95 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Configure, review, or troubleshoot Rsbuild applications, including build/dev commands, assets, type checking, and bundle optimization.

AI 產生的概覽

用於設定、審查與疑難排解 Rsbuild 應用程式的指南,涵蓋 CLI、型別檢查、資源與打包體積。

功能
提供一套用於撰寫或審查 Rsbuild 專案的最佳實務規則。內容涵蓋設定慣例、CLI 指令、型別檢查選項、打包體積最佳化、資源管理、安全性、偵錯與效能分析。它產出的是建議性指引,而非檔案或程式碼。
適用情境
適用於建置、審查或疑難排解 Rsbuild 專案時。也適合用來診斷建置設定、打包體積或資源處理的問題。
執行需求
除代理外不需其他工具或套件;僅為說明性內容,不附帶指令碼。內容在概念上涉及 Rsbuild、Rspack 與 TypeScript 工具鏈。

Rsbuild best practices

Apply these rules when writing or reviewing Rsbuild projects.

Configuration

  • Use rsbuild.config.ts and defineConfig
  • Use tools.rspack or tools.bundlerChain only when no first-class Rsbuild option exists
  • Define explicit source.entry values for multi-page applications
  • In TypeScript projects, prefer tsconfig.json path aliases first

CLI

  • Use rsbuild for local development
  • Use rsbuild build for production build
  • Use rsbuild preview only for local production preview
  • Use rsbuild inspect to inspect final Rsbuild/Rspack configs

Type checking

  • Use @rsbuild/plugin-type-check for integrated dev/build type checks
  • Or run tsc --noEmit/vue-tsc --noEmit as 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 public files by absolute URL path

Security

  • Do not publish .map files to public servers/CDNs when production source maps are enabled

Debugging

  • Run with DEBUG=rsbuild when diagnosing config resolution or plugin behavior
  • Read generated files in dist/.rsbuild to confirm final config, not assumed config

Profiling

  • Use Node CPU profiling (--cpu-prof) when JavaScript-side overhead is suspected
  • Use RSPACK_PROFILE=OVERVIEW and analyze trace output for compiler-phase bottlenecks

Documentation

來源與署名

來源:rstackjs/agent-skills位於skills/rsbuild-best-practices提交2966acb

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架