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