StarModel 邀请活动
← 返回 Skill 列表
extension
分类: 开发与工程API Key 暂未确认

vite-react-best-practices

全面的React和Vite单页应用性能、架构及部署指南。在构建、审查或重构使用Vite构建的React应用程序(SPA)时运用此技能。涵盖Vite特定的构建配置、静态托管需求以及核心的React性能模式。

person作者: jakexiaohubgithub

Vite React Best Practices

A senior-level guide for building production-ready React Single Page Applications (SPAs) with Vite.

When to Apply

Reference these guidelines when:

  • Setting up a new Vite + React project
  • Configuring build pipelines and CI/CD for SPAs
  • Troubleshooting production build or caching issues
  • Refactoring React components for performance

Priority Table

| Impact | Rules | | --- | --- | | CRITICAL | Static Rewrites, Caching Strategy | | HIGH | Build Validation, Environment Variables, Route Splitting, Server State | | MEDIUM | Memoization, Image Optimization, Colocation, Anti-Patterns: Import from Dist, Troubleshooting |

Rule Categories

1. Vite SPA Deployment (CRITICAL)

2. React Core Performance

3. Architecture & Cleanup

How to Use

  1. Pick the rule that matches the task from the categories above, or from the priority table if you need to know what must not be skipped.
  2. Open the rule file in rules/. Each file is self-contained: frontmatter with impact and tags, the rationale, an incorrect example, a correct example, and a References section.
  3. Load only the rules relevant to the task. CRITICAL rules apply to every Vite SPA; HIGH rules apply to most production apps; MEDIUM rules apply when the area is being changed.
  4. When a rule references another rule, follow the relative link inside rules/.

| Stack | Version | | --- | --- | | React | 19.3.1 | | Vite | 8.3.5 (Rolldown + Oxc) | | React Router | 8.5.1 | | TanStack Query | 5.105.1 | | React Compiler | babel-plugin-react-compiler 1.x | | Node (Vite 8) | ^20.19.0 || >=22.12.0 |

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md (also available as CLAUDE.md).