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 从公开仓库中收录这些内容。

举报或申请下架