react-vite-best-practices
БесплатноБез исполняемых скриптовНе проверенReact and Vite performance optimization guidelines. Use when writing, reviewing, or optimizing React components built with Vite. Targets Vite 8 (Rolldown…
Об этом скилле
React + Vite Best Practices
Comprehensive performance optimization guide for React applications built with Vite. Targets Vite 8.x (Rolldown bundler, Oxc compiler), @vitejs/plugin-react 6 and React 19. Contains 24 rules across 6 categories for build optimization, code splitting, development performance, asset handling, environment configuration, and bundle analysis.
Metadata
- Version: 3.0.0
- Framework: React + Vite
- Target: Vite 8.x (Rolldown, Oxc), @vitejs/plugin-react 6, React 19
- Updated: November 2026
- Rule Count: 24 rules across 6 categories
- License: MIT
When to Apply
Reference these guidelines when:
- Configuring Vite for React projects
- Moving a Vite 7 config to Vite 8 (Rolldown, Oxc)
- Implementing code splitting and lazy loading
- Optimizing build output and bundle size
- Setting up development environment and HMR
- Handling images, fonts, SVGs, and static assets
- Managing environment variables across environments
- Analyzing bundle size and dependencies
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Build Optimization | CRITICAL | build- |
| 2 | Code Splitting | CRITICAL | split- |
| 3 | Development | HIGH | dev- |
| 4 | Asset Handling | HIGH | asset- |
| 5 | Environment Config | MEDIUM | env- |
| 6 | Bundle Analysis | MEDIUM | bundle- |
Quick Reference
1. Build Optimization (CRITICAL)
build-vite8-config- Vite 8 option names (rolldownOptions, oxc, codeSplitting, tsconfigPaths, React Compiler)build-manual-chunks- Vendor chunk groups with codeSplittingbuild-minification- Minification with OXC (default) or Terserbuild-target-modern- Target modern browsers (baseline-widely-available)build-sourcemaps- Configure sourcemaps per environmentbuild-tree-shaking- Ensure proper tree shaking with ESMbuild-compression- Gzip and Brotli compressionbuild-asset-hashing- Content-based hashing for cache busting
2. Code Splitting (CRITICAL)
split-route-lazy- Route-based splitting with React.lazy()split-suspense-boundaries- Strategic Suspense boundary placementsplit-dynamic-imports- Dynamic import() for heavy componentssplit-component-lazy- Lazy load non-critical componentssplit-prefetch-hints- Prefetch chunks on hover/idle/viewport
3. Development (HIGH)
dev-dependency-prebundling- Configure optimizeDeps for faster startsdev-fast-refresh- React Fast Refresh patternsdev-hmr-config- HMR server configuration
4. Asset Handling (HIGH)
asset-image-optimization- Image optimization and lazy loadingasset-svg-components- SVGs as React components with SVGRasset-fonts- Web font loading strategyasset-public-dir- Public directory vs JavaScript imports
5. Environment Config (MEDIUM)
env-vite-prefix- VITE_ prefix for client variablesenv-modes- Mode-specific environment filesenv-sensitive-data- Never expose secrets in client code
6. Bundle Analysis (MEDIUM)
bundle-visualizer- Analyze bundles with rollup-plugin-visualizer
Essential Configurations
Recommended vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(import.meta.dirname, './src'),
},
},
build: {
target: 'baseline-widely-available',
sourcemap: false,
chunkSizeWarningLimit: 500,
rolldownOptions: {
output: {
codeSplitting: {
groups: [
{
name: 'vendor',
test: /[\\/]node_modules[\\/](react|react-dom|scheduler)[\\/]/,
},
],
},
},
},
},
optimizeDeps: {
include: ['react', 'react-dom'],
},
server: {
port: 3000,
hmr: {
overlay: true,
},
},
})
Route-Based Code Splitting
import { lazy, Suspense } from 'react'
const Home = lazy(() => import('./pages/Home'))
const Dashboard = lazy(() => import('./pages/Dashboard'))
const Settings = lazy(() => import('./pages/Settings'))
function App() {
return (
<Suspense fallback={<LoadingSpinner />}>
{/* Routes here */}
</Suspense>
)
}
Environment Variables
// src/vite-env.d.ts
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_API_URL: string
readonly VITE_APP_TITLE: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
How to Use
Read individual rule files for detailed explanations and code examples:
rules/build-vite8-config.md
rules/build-manual-chunks.md
rules/split-route-lazy.md
rules/env-vite-prefix.md
References
- Vite Documentation
- React Documentation
- Rolldown Documentation
- [Vite 8 Migration](htt
Установить react-vite-best-practices в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл react-vite-best-practices?
React and Vite performance optimization guidelines. Use when writing, reviewing, or optimizing React components built with Vite. Targets Vite 8 (Rolldown, Oxc), @vitejs/plugin-react 6 and React 19. Triggers on tasks involving Vite configuration, Vite 8 migration, build optimization, code splitting, lazy loading, HMR, bundle size, or React performance.
Как установить скилл react-vite-best-practices?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react-vite-best-practices запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic