关于 vite
vite 是面向 Vite 开发者的文档参考技能,将问题对应到指南、配置和插件资料,涵盖开发、构建、SSR、部署及 API。
主要功能
- 01指南主题参考映射
- 02Vite 配置资料
- 03插件选择指南
- 04CLI 与 API 内容
- 05SSR 和部署主题
适用场景
- 01查找 Vite 配置指南
- 02选择 Vite 插件
- 03使用 HMR 或 JavaScript API
- 04排查 SSR 或部署配置
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ partme-ai/ full-stack-skills --skill vite安装后在 Claude Code 中输入/vite确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
api/cli.mdconfig.mdplugin-api.mdexamples/config/build-options.mdconfiguring-vite.mddep-optimization-options.mdpreview-options.mdserver-options.mdshared-options.mdssr-options.mdworker-options.mdexamples/guide/api-environment-frameworks.mdapi-environment-instances.mdapi-environment-plugins.mdapi-environment-runtimes.mdapi-environment.mdapi-hmr.mdapi-javascript.mdapi-plugin.mdassets.mdbackend-integration.mdbuild.mdcli.mddep-pre-bundling.mdenv-and-mode.mdfeatures.mdgetting-started.mdmigration.mdperformance.mdphilosophy.md详细介绍
适用场景
在用户想要执行以下操作时使用此技能:
- 学习 Vite 指南中的主题,从入门到性能优化
- 使用官方配置参考配置 Vite
- 从官方插件页面选择或了解 Vite 插件
- 使用 Vite CLI、HMR API 或 JavaScript API
- 处理 Vite 中的 SSR、后端集成或部署场景
使用方法
- 确定主题,根据用户的请求进行判断。
- 打开匹配的指南示例文件,路径为
examples/guide/。 - 如果需要配置,打开
examples/config/中匹配的文件。 - 如果需要选择插件,打开
examples/plugins.md。 - 严格遵循官方文档,确保输出与引用页面一致。
- 验证:运行
npm run build,确认配置更改可以编译;运行npm run preview,测试生产环境输出。
指南映射(一一对应 https://cn.vitejs.dev/guide/)
简介
examples/guide/getting-started.md→ https://cn.vitejs.dev/guide/examples/guide/philosophy.md→ https://cn.vitejs.dev/guide/philosophy.htmlexamples/guide/why-vite.md→ https://cn.vitejs.dev/guide/why.html
指南
examples/guide/features.md→ https://cn.vitejs.dev/guide/features.htmlexamples/guide/cli.md→ https://cn.vitejs.dev/guide/cli.htmlexamples/guide/using-plugins.md→ https://cn.vitejs.dev/guide/using-plugins.htmlexamples/guide/dep-pre-bundling.md→ https://cn.vitejs.dev/guide/dep-pre-bundling.htmlexamples/guide/assets.md→ https://cn.vitejs.dev/guide/assets.htmlexamples/guide/build.md→ https://cn.vitejs.dev/guide/build.htmlexamples/guide/static-deploy.md→ https://cn.vitejs.dev/guide/static-deploy.htmlexamples/guide/env-and-mode.md→ https://cn.vitejs.dev/guide/env-and-mode.htmlexamples/guide/ssr.md→ https://cn.vitejs.dev/guide/ssr.htmlexamples/guide/backend-integration.md→ https://cn.vitejs.dev/guide/backend-integration.htmlexamples/guide/troubleshooting.md→ https://cn.vitejs.dev/guide/troubleshooting.htmlexamples/guide/performance.md→ https://cn.vitejs.dev/guide/performance.htmlexamples/guide/migration.md→ https://cn.vitejs.dev/guide/migration.html
API
examples/guide/api-plugin.md→ https://cn.vitejs.dev/guide/api-plugin.htmlexamples/guide/api-hmr.md→ https://cn.vitejs.dev/guide/api-hmr.htmlexamples/guide/api-javascript.md→ https://cn.vitejs.dev/guide/api-javascript.html
环境 API
examples/guide/api-environment.md→ https://cn.vitejs.dev/guide/api-environment.htmlexamples/guide/api-environment-instances.md→ https://cn.vitejs.dev/guide/api-environment-instances.htmlexamples/guide/api-environment-plugins.md→ https://cn.vitejs.dev/guide/api-environment-plugins.htmlexamples/guide/api-environment-frameworks.md→ https://cn.vitejs.dev/guide/api-environment-frameworks.htmlexamples/guide/api-environment-runtimes.md→ https://cn.vitejs.dev/guide/api-environment-runtimes.html
配置映射(一一对应 https://cn.vitejs.dev/config/)
examples/config/configuring-vite.md→ https://cn.vitejs.dev/config/examples/config/shared-options.md→ https://cn.vitejs.dev/config/shared-options.htmlexamples/config/server-options.md→ https://cn.vitejs.dev/config/server-options.htmlexamples/config/build-options.md→ https://cn.vitejs.dev/config/build-options.htmlexamples/config/preview-options.md→ https://cn.vitejs.dev/config/preview-options.htmlexamples/config/dep-optimization-options.md→ https://cn.vitejs.dev/config/dep-optimization-options.htmlexamples/config/ssr-options.md→ https://cn.vitejs.dev/config/ssr-options.htmlexamples/config/worker-options.md→ https://cn.vitejs.dev/config/worker-options.html
插件映射(一一对应 https://cn.vitejs.dev/plugins/)
examples/plugins.md→ https://cn.vitejs.dev/plugins/
内联快速开始
# Create a new Vite project
npm create vite@latest my-app -- --template react-ts
# Install and run
cd my-app && npm install
npm run dev # Dev server with HMR
npm run build # Production build
npm run preview # Preview production build
// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
proxy: {
'/api': 'http://localhost:8080',
},
},
build: {
sourcemap: true,
rollupOptions: {
output: {
manualChunks: { vendor: ['react', 'react-dom'] },
},
},
},
});
最佳实践
- 使用
defineConfig获取 TypeScript 类型提示和自动补全 - 在
server.proxy中配置代理,以便在开发期间调用 API - 使用
build.rollupOptions.output.manualChunks拆分供应商代码 - 在开发环境中启用 source map;在生产环境中禁用,以减小构建体积
- 使用
import.meta.env获取环境变量(以VITE_为前缀)
资源
关键词
Vite、构建工具、开发服务器、HMR、配置、插件、SSR、CLI、依赖预打包、资源
评论
支持 Markdown