vite
它能做什么
这项技能说明如何设置和配置 Vite。Vite 是一个用于运行和打包现代网页项目的构建工具。适合需要快速开发服务器或生产构建的开发者。
适用场景
- ✓当你在网页项目中设置或修改 vite.config 文件时。
- ✓当你想编写或使用 Vite 插件时。
- ✓当你想用 Vite 构建库或服务端渲染应用时。
技能链接
https://github.com/antfu/skills/blob/main/skills/vite/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请更新我的 Vite 配置,使项目以库的形式构建,并保留现有的 TypeScript 设置。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体读取项目的 Vite 配置,并遵循 Vite 关于设置、插件和构建的指导,包括较新的 Rolldown 打包器。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Vite
Based on Vite v8.3.1 (Rolldown-powered), generated at 2026-09-25. Vite 8 uses the Rolldown bundler and the Oxc transformer instead of esbuild + Rollup.
Vite is a next-generation frontend build tool with fast dev server (native ESM + HMR) and optimized production builds.
Preferences
- Use TypeScript: prefer
vite.config.ts - Always use ESM, avoid CommonJS
Core
| Topic | Description | Reference |
|---|---|---|
| Configuration | vite.config.ts, defineConfig, conditional configs, loadEnv |
core-config |
| Features | import.meta.glob, asset queries (?raw, ?url), import.meta.env, HMR API |
core-features |
| Plugin API | Vite-specific hooks, virtual modules, plugin ordering | core-plugin-api |
Build & SSR
| Topic | Description | Reference |
|---|---|---|
| Build & SSR | Library mode, SSR middleware mode, ssrLoadModule, JavaScript API |
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 |
Quick Reference
CLI Commands
vite # Start dev server
vite build # Production build
vite preview # Preview production build
vite build --ssr # SSR build
Common Config
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
@vitejs/plugin-vue- Vue 3 SFC support@vitejs/plugin-vue-jsx- Vue 3 JSX@vitejs/plugin-react- React with Oxc/Babel@vitejs/plugin-react-swc- React with SWC@vitejs/plugin-legacy- Legacy browser support
常见问题
它涵盖最新版本的 Vite 吗?
涵盖。它基于 Vite 8,并说明了向 Rolldown 打包器的转变。
它更推荐 TypeScript 配置文件吗?
是的。它推荐使用 vite.config.ts 文件,并使用 ES 模块而不是 CommonJS。
它能帮助服务端渲染吗?
能。指导涵盖服务端渲染和库模式。
详情
作者的原始描述
Vite build tool configuration, plugin API, SSR, and Vite 8 Rolldown migration. Use when working with Vite projects, vite.config.ts, Vite plugins, or building libraries/SSR apps with Vite.
repo: antfu/skills
热度
- GitHub 星标
- 6.0k
- 排名
- #14445
- 许可证
- MIT
- 更新时间
- 2026/10/30
评论
- …