AGENT SKILL

stack-vite

Vite frontend build tool — configuration, plugins, asset loading

License 许可
Apache-2.0
最近更新
2026-11-15
Stars
★ 3
Forks
0

01 前言 Front Matter

name
stack-vite
license
Apache-2.0
metadata
{ "author": "manuel-retamozo-garcia", "version": "1.0" }
description
Vite frontend build tool — configuration, plugins, asset loading
capabilities
[ "vite" ]

02 资源文件 1

03 SKILL.md 正文

Vite Patterns

Build tool and dev server patterns for Vite 8+ projects. Covers configuration, environment variables, proxy setup, library mode, dependency pre-bundling, and common production pitfalls.

When to Use

  • Configuring vite.config.ts or vite.config.js
  • Setting up environment variables or .env files
  • Configuring dev server proxy for API backends
  • Optimizing build output (chunks, minification, assets)
  • Publishing libraries with build.lib
  • Troubleshooting dependency pre-bundling or CJS/ESM interop

Core Rules

  1. Dev vs Build Engines: Dev serves files as native ESM (transpiled on demand via esbuild). Production builds use Rolldown/Rollup. Always smoke-test with vite preview before deploying.
  2. Type Checking Gap: Vite build transpiles but does NOT type-check. You must run tsc --noEmit in CI or use vite-plugin-checker.
  3. Environment Security: Only VITE_-prefixed environment variables are exposed to the client. Secrets must NEVER use the prefix. Never pass empty string loadEnv(mode, cwd, '') as it leaks server secrets.
  4. Performance Aliases: Avoid hand-rolling aliases. Use vite-tsconfig-paths to reuse tsconfig.json configurations.
  5. Barrel Files: Avoid importing from index/barrel files in the dev server hot-path as it triggers loading of all re-exported files.

References

For full code examples, plugin configurations, manual chunk setups, and server proxy details, refer to:

04 同仓库更多 Skills