Vite build optimization
Configures Vite for rapid HMR and optimized chunk splitting. Use when auditing build pipelines, configuring environment variables, or optimizing client payloads.From its SKILL.md
npx -y skills add meyverick/agy-skills --skill vite-build-optimizationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.6 KB, 503 tokens by cl100k_base, as published. Nobody here has run it
Vite Build Optimization
This skill configures the Vite bundler to achieve lightning-fast Hot Module Replacement (HMR) during development and highly optimized, cache-efficient chunks for production deployment.
When to Use
- Use when modifying
vite.config.tsorvite.config.js. - Use when the production build bundle sizes are too large.
- Use when configuring secure frontend environment variables.
- NOT for modifying server-side Node.js environment files without Vite involvement.
Core Process
Phase 1: Rapid HMR Configuration
- Ensure server configurations specifically define explicit paths or watcher settings if working inside heavy Docker containers.
- Avoid heavy runtime plugins that hook into every file transform unless absolutely necessary.
Phase 2: Production Chunk Splitting
By default, Rollup bundles everything into a monolithic file. Break this down:
- Utilize
build.rollupOptions.output.manualChunksto explicitly split vendor libraries (e.g.,react,svelte,three) from application code. - This allows browsers to cache stable dependencies while only downloading the latest application logic.
Phase 3: Secure Environment Variable Injection
Vite exposes environment variables differently than Node.
- Only variables prefixed with
VITE_are exposed to the client bundle. - Ensure secrets are never prefixed with
VITE_. - Access variables securely via
import.meta.env.VITE_MY_VAR(do not useprocess.env).
Common Rationalizations
| Rationalization | Reality |
|---|---|
| "I'll just let Vite handle chunking automatically." | Default chunking often results in massive index files. Explicit manual chunking is required for high-performance delivery. |
"I'll read this secret via process.env in my component." | process.env is not injected by Vite. If the secret is meant for the client, it must be prefixed with VITE_ and accessed via import.meta.env. |
Red Flags
vite.config.tslacking explicitmanualChunksoptimization for vendor libraries.- Client-side code attempting to read non-prefixed
.envvariables.
Verification
Before finalizing the build optimization:
-
npm run buildexecutes without Rollup warnings regarding chunk size limits. - Vendor libraries are properly isolated into separate chunks.
- Client environment variables are correctly prefixed with
VITE_.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.