vite
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVite
Vite
Based on Vite 8 beta (Rolldown-powered). Vite 8 uses Rolldown bundler and Oxc transformer.
Vite is a next-generation frontend build tool with fast dev server (native ESM + HMR) and optimized production builds.
基于 Vite 8 测试版(由 Rolldown 驱动)。Vite 8 采用 Rolldown 打包器和 Oxc 转换器。
Vite 是一款下一代前端构建工具,拥有快速的开发服务器(原生 ESM + HMR)和优化的生产构建能力。
Preferences
偏好设置
- Use TypeScript: prefer
vite.config.ts - Always use ESM, avoid CommonJS
- 使用 TypeScript:优先选择
vite.config.ts - 始终使用 ESM,避免使用 CommonJS
Core
核心内容
| Topic | Description | Reference |
|---|---|---|
| Configuration | | core-config |
| Features | | core-features |
| Plugin API | Vite-specific hooks, virtual modules, plugin ordering | core-plugin-api |
| 主题 | 描述 | 参考文档 |
|---|---|---|
| 配置 | | core-config |
| 功能特性 | | core-features |
| 插件 API | Vite 专属钩子、虚拟模块、插件执行顺序 | core-plugin-api |
Build & SSR
构建与 SSR
| Topic | Description | Reference |
|---|---|---|
| Build & SSR | Library mode, SSR middleware mode, | build-and-ssr |
| 主题 | 描述 | 参考文档 |
|---|---|---|
| 构建与 SSR | 类库模式、SSR 中间件模式、 | build-and-ssr |
Advanced
进阶内容
| Topic | Description | Reference |
|---|---|---|
| Environment API | Vite 6+ multi-environment support, custom runtimes | environment-api |
| Rolldown Migration | Vite 8 changes: Rolldown bundler, Oxc transformer, config migration | rolldown-migration |
| 主题 | 描述 | 参考文档 |
|---|---|---|
| 环境 API | Vite 6+ 多环境支持、自定义运行时 | environment-api |
| Rolldown 迁移 | Vite 8 变更点:Rolldown 打包器、Oxc 转换器、配置迁移 | rolldown-migration |
Quick Reference
快速参考
CLI Commands
CLI 命令
bash
vite # Start dev server
vite build # Production build
vite preview # Preview production build
vite build --ssr # SSR buildbash
vite # 启动开发服务器
vite build # 生产构建
vite preview # 预览生产构建产物
vite build --ssr # SSR 构建Common Config
通用配置
ts
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [],
resolve: { alias: { '@': '/src' } },
server: { port: 3000, proxy: { '/api': 'http://localhost:8080' } },
build: { target: 'esnext', outDir: 'dist' },
})ts
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [],
resolve: { alias: { '@': '/src' } },
server: { port: 3000, proxy: { '/api': 'http://localhost:8080' } },
build: { target: 'esnext', outDir: 'dist' },
})Official Plugins
官方插件
- - Vue 3 SFC support
@vitejs/plugin-vue - - Vue 3 JSX
@vitejs/plugin-vue-jsx - - React with Oxc/Babel
@vitejs/plugin-react - - React with SWC
@vitejs/plugin-react-swc - - Legacy browser support
@vitejs/plugin-legacy
- - Vue 3 单文件组件支持
@vitejs/plugin-vue - - Vue 3 JSX 支持
@vitejs/plugin-vue-jsx - - 基于 Oxc/Babel 的 React 支持
@vitejs/plugin-react - - 基于 SWC 的 React 支持
@vitejs/plugin-react-swc - - 旧版浏览器支持
@vitejs/plugin-legacy