vite
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVite
Vite
When to use
使用场景
- User asks how to set up or run a Vite project.
- User needs Vite configuration guidance ().
vite.config.* - User needs plugin authoring, HMR, or JS API usage.
- User needs environment variables or modes behavior.
- 用户询问如何搭建或运行Vite项目。
- 用户需要Vite配置指导()。
vite.config.* - 用户需要插件开发、HMR或JS API使用相关指导。
- 用户需要环境变量或模式行为相关说明。
Quick navigation
快速导航
- Getting started: references/getting-started.md
- Philosophy and rationale: references/philosophy.md, references/why-vite.md
- Features: references/features.md
- CLI: references/cli.md
- Plugins (usage): references/using-plugins.md
- Plugin API: references/api-plugin.md
- HMR API: references/api-hmr.md
- JavaScript API: references/api-javascript.md
- Config reference: references/config.md
- Dependency optimization: references/dep-pre-bundling.md
- Assets: references/assets.md
- Build: references/build.md
- Static deploy: references/static-deploy.md
- Env & modes: references/env-and-mode.md
- SSR: references/ssr.md
- Backend integration: references/backend-integration.md
- Troubleshooting: references/troubleshooting.md
- Performance: references/performance.md
- Rolldown: references/rolldown.md
- Migration: references/migration.md
- Breaking changes: references/breaking-changes.md
- Environment API: references/api-environment.md
- Environment instances: references/api-environment-instances.md
- Env plugins: references/api-environment-plugins.md
- Env frameworks: references/api-environment-frameworks.md
- Env runtimes: references/api-environment-runtimes.md
- 入门指南:references/getting-started.md
- 设计理念与原理:references/philosophy.md, references/why-vite.md
- 功能特性:references/features.md
- 命令行工具:references/cli.md
- 插件(使用):references/using-plugins.md
- 插件API:references/api-plugin.md
- HMR API:references/api-hmr.md
- JavaScript API:references/api-javascript.md
- 配置参考:references/config.md
- 依赖优化:references/dep-pre-bundling.md
- 资源处理:references/assets.md
- 构建:references/build.md
- 静态部署:references/static-deploy.md
- 环境与模式:references/env-and-mode.md
- 服务端渲染:references/ssr.md
- 后端集成:references/backend-integration.md
- 故障排查:references/troubleshooting.md
- 性能优化:references/performance.md
- Rolldown:references/rolldown.md
- 迁移指南:references/migration.md
- 重大变更:references/breaking-changes.md
- Environment API:references/api-environment.md
- Environment实例:references/api-environment-instances.md
- Env插件:references/api-environment-plugins.md
- Env框架:references/api-environment-frameworks.md
- Env运行时:references/api-environment-runtimes.md
Core rules
核心规则
- Prefer minimal configuration; extend only as needed.
- Keep as a first-class entry point when using Vite defaults.
index.html - Treat dev server settings and build settings separately.
- Document mode-dependent behavior for env variables and .
define - Use config to opt-in to deprecation warnings before migration.
future
- 优先使用极简配置;仅在必要时进行扩展。
- 使用Vite默认配置时,将作为一等入口文件。
index.html - 区分开发服务器设置与构建设置。
- 记录环境变量和的模式相关行为。
define - 使用配置在迁移前启用弃用警告。
future
Recipes
实践方案
- Scaffold a project with .
npm create vite@latest - Configure aliases, server options, and build outputs in .
vite.config.* - Load values into config with
.envwhen config needs them.loadEnv - Add plugins with and define
plugins: []orapplywhen needed.enforce - Use HMR APIs for fine-grained updates when plugin or framework needs it.
- Use when deps aren't discovered on startup.
optimizeDeps.include/exclude - Use for multi-page apps.
build.rollupOptions.input - Enable deprecation warnings: .
future: { removeSsrLoadModule: 'warn' } - Use hook instead of
hotUpdatefor environment-aware HMR.handleHotUpdate - Use instead of
this.environmentin plugin hooks.options.ssr
- 使用搭建项目。
npm create vite@latest - 在中配置别名、服务器选项和构建输出。
vite.config.* - 当配置需要时,使用将
loadEnv中的值加载到配置中。.env - 使用添加插件,并在必要时定义
plugins: []或apply。enforce - 当插件或框架需要时,使用HMR API进行细粒度更新。
- 当启动时未检测到依赖项时,使用。
optimizeDeps.include/exclude - 针对多页面应用使用。
build.rollupOptions.input - 启用弃用警告:。
future: { removeSsrLoadModule: 'warn' } - 针对感知环境的HMR,使用钩子而非
hotUpdate。handleHotUpdate - 在插件钩子中使用而非
this.environment。options.ssr
Prohibitions
禁止事项
- Do not copy large verbatim chunks from vendor docs.
- Do not assume framework-specific behavior without verifying.
- 不要直接复制供应商文档中的大段内容。
- 不要在未验证的情况下假设框架特定行为。