← 返回 Skills 市场
bovinphang

Vite Project Standard

作者 Bovin Phang · GitHub ↗ · v2.5.0 · MIT-0
cross-platform ✓ 安全检测通过
40
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install fec-vite-project-standard
功能描述
Use when creating, configuring, reviewing, or debugging Vite-based frontend projects, vite.config.ts, env variables, dev server proxy, HMR, plugin ordering,...
使用说明 (SKILL.md)

Vite 项目规范

适用于 Vite 应用、组件库、开发服务器和构建配置的设计与审查。

Purpose

规范 Vite 配置、安全边界和构建性能,避免开发环境与生产构建的常见陷阱。

Procedure

  1. 识别项目类型

    • 应用项目优先检查 rootbaseserver.proxyenvPrefixbuild 和框架插件。
    • 组件库项目优先检查 build.lib、类型产物、peer dependencies external 和导出入口。
    • Monorepo 额外检查 server.fs.allow、路径别名和包依赖边界。
  2. 选择插件

    • React 默认优先 @vitejs/plugin-react-swc;需要 Babel 插件时才用 @vitejs/plugin-react
    • Vue 项目使用 @vitejs/plugin-vue,路径别名优先交给 vite-tsconfig-paths
    • TypeScript 项目必须通过 tsc --noEmit、CI 或 vite-plugin-checker 补齐类型检查。
  3. 管理环境变量

    • 客户端只读取明确公开的前缀,如 VITE_
    • loadEnv 第三个参数使用显式前缀数组,不使用空字符串加载全部变量。
    • 密钥、数据库地址、私有 token 必须留在服务端或构建系统,不进入客户端 bundle。
  4. 优化开发体验

    • 慢启动先用 vite --profile 定位插件、解析或预构建瓶颈。
    • 对 CJS/UMD 依赖用 optimizeDeps.include 处理互操作问题。
    • 大项目可用 server.warmup.clientFiles 预热核心入口。
  5. 优化生产构建

    • 发布前运行 vite build,并用 vite preview 做本地构建烟测。
    • 手动分包使用稳定的对象形式优先,避免把每个依赖拆成独立小 chunk。
    • 生产 sourcemap 默认关闭;若上传错误追踪平台,上传后不随站点公开。
    • 动效、3D、图表、编辑器、地图和音视频处理库优先通过动态导入或路由级拆包隔离。
    • 检查静态资源是否进入正确目录、是否被 hash/cache、是否存在占位 URL 或过大的未压缩媒体。

Minimal Config

import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react-swc";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), ["VITE_"]);

  return {
    plugins: [react(), tsconfigPaths()],
    define: {
      __PUBLIC_API_URL__: JSON.stringify(env.VITE_API_URL),
    },
    server: {
      proxy: {
        "/api": {
          target: "http://localhost:8080",
          changeOrigin: true,
        },
      },
    },
  };
});

Constraints

  • vite build 只转译和打包,不等于类型检查;CI 必须另跑 typecheck。
  • VITE_ 不是安全边界;任何 VITE_ 变量都会进入客户端包。
  • 不设置 envPrefix: "",不使用 loadEnv(mode, root, "") 后再随意 define
  • 不默认引入 legacy 插件;只有真实用户数据需要时再启用。
  • 不用 vite preview 作为生产服务器。
  • 组件库必须 externalize peer dependencies,并单独产出 .d.ts
  • 不把服务端密钥通过 defineimport.meta.env 或空前缀 loadEnv 注入客户端。
  • 不把 GSAP、Three.js、Lottie、Monaco、地图 SDK 等重型库放进所有页面共享入口;先评估 async chunk 和首屏影响。

Expected Output

输出应包含项目类型判断、关键配置变更、环境变量安全说明、构建/开发性能验证方式。完成后 Vite 配置应可类型检查、可构建、密钥不泄露,并能解释 dev 与 build 的差异。

安全使用建议
This skill appears safe to install for Vite project work. Be aware it may activate for many Vite-related frontend tasks, so users who prefer narrower routing may want clearer trigger wording, but the artifact itself is documentation-only and does not perform actions on its own.
能力评估
Purpose & Capability
The stated purpose is to guide Vite project configuration, security boundaries, and build performance; SKILL.md instructions align with that purpose and include protective guidance about environment variables and secrets.
Instruction Scope
The activation description is fairly broad across Vite creation, configuration, review, and debugging, but it remains bounded to Vite-related work and explicitly points framework architecture tasks to separate skills.
Install Mechanism
The package contains only markdown and JSON artifacts and no dependencies, install scripts, or executable files. There is a minor version metadata mismatch between package/artifact metadata and outer scan metadata, but no security-impacting install behavior is shown.
Credentials
Recommended commands and configuration examples are proportionate to Vite development, such as build, preview, profiling, type checking, proxy configuration, and dependency optimization.
Persistence & Privilege
No background workers, persistence, privilege escalation, credential-store access, or local profile/session use are present; credential handling is limited to advice not to expose secrets in client bundles.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install fec-vite-project-standard
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /fec-vite-project-standard 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v2.5.0
Version 2.5.0 - Added comprehensive SKILL.md detailing procedures and constraints for configuring and reviewing Vite-based frontend projects. - Clarified best practices for plugin selection, environment variable management, and dev/build performance optimization. - Provided minimal Vite config code sample for standard usage. - Outlined specific security guidelines to prevent exposure of sensitive data in client bundles. - Documented expected outputs and clear boundaries for project and library types.
元数据
Slug fec-vite-project-standard
版本 2.5.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Vite Project Standard 是什么?

Use when creating, configuring, reviewing, or debugging Vite-based frontend projects, vite.config.ts, env variables, dev server proxy, HMR, plugin ordering,... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 40 次。

如何安装 Vite Project Standard?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install fec-vite-project-standard」即可一键安装,无需额外配置。

Vite Project Standard 是免费的吗?

是的,Vite Project Standard 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Vite Project Standard 支持哪些平台?

Vite Project Standard 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Vite Project Standard?

由 Bovin Phang(@bovinphang)开发并维护,当前版本 v2.5.0。

💬 留言讨论