vite-patterns
Helps your agent configure and optimize Vite, a build tool. It allows fine-tuning the build process, managing dependencies, and improving web project performance.
What it does
This skill helps you configure and optimize Vite, a tool used for building web projects. It explains how Vite works, how to adjust its settings, and how to use plugins to add features.
When to use it
- ✓When configuring the `vite.config.ts` file.
- ✓When adjusting how Vite prepares your project for production.
- ✓When troubleshooting issues with the development server or build process.
Example of what to ask your AI
“How do I configure Vite to use an API proxy?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
Vite uses a fast development server that transforms your code on demand. For production, it bundles your code using tools like Rollup or Rolldown, optimizing size and performance. It also pre-bundles dependencies to speed up startup.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add affaan-m/ECC --skill vite-patternsOr download just the file:
curl -L https://raw.githubusercontent.com/affaan-m/ECC/main/pi/core/skills/vite-patterns/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
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.tsorvite.config.js - Setting up environment variables or
.envfiles - 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
- Debugging HMR, dev server, or build errors
- Choosing or ordering Vite plugins
How It Works
- Dev mode serves source files as native ESM — no bundling. Transforms happen on-demand per module request, which is why cold starts are fast and HMR is precise.
- Build mode uses Rolldown (v7+) or Rollup (v5–v6) to bundle the app for production with tree-shaking, code-splitting, and Oxc-based minification.
- Dependency pre-bundling converts CJS/UMD deps to ESM once via esbuild and caches the result under
node_modules/.vite, so subsequent starts skip the work. - Plugins share a unified interface across dev and build — the same plugin object works for both the dev server's on-demand transforms and the production pipeline.
- Environment variables are statically inlined at build time.
VITE_-prefixed vars become public constants in the bundle; everything unprefixed is invisible to client code.
Examples
Config Structure
Basic Config
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
resolve: {
alias: { '@': new URL('./src', import.meta.url).pathname },
},
})
Conditional Config
// vite.config.ts
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd()) // VITE_ prefixed only (safe)
return {
plugins: [react()],
server: command === 'serve' ? { port: 3000 } : undefined,
define: {
__API_URL__: JSON.stringify(env.VITE_API_URL),
},
}
})
Key Config Options
| Key | Default | Description |
|---|---|---|
root |
'.' |
Project root (where index.html lives) |
base |
'/' |
Public base path for deployed assets |
envPrefix |
'VITE_' |
Prefix for client-exposed env vars |
build.outDir |
'dist' |
Output directory |
build.minify |
'oxc' |
Minifier ('oxc', 'terser', or false) |
build.sourcemap |
false |
true, 'inline', or 'hidden' |
Plugins
Essential Plugins
Most plugin needs are covered by a handful of well-maintained packages. Reach for these before writing your own.
| Plugin | Purpose | When to use |
|---|---|---|
@vitejs/plugin-react-swc |
React HMR + Fast Refresh via SWC | Default for React apps (faster than Babel variant) |
@vitejs/plugin-react |
React HMR + Fast Refresh via Babel | Only if you need Babel plugins (emotion, MobX decorators) |
@vitejs/plugin-vue |
Vue 3 SFC support | Vue apps |
vite-plugin-checker |
Runs tsc + ESLint in worker thread with HMR overlay |
Any TypeScript app — Vite does NOT type-check during vite build |
vite-tsconfig-paths |
Honors tsconfig.json paths aliases |
Any time you already have aliases in tsconfig.json |
vite-plugin-dts |
Emits .d.ts files in library mode |
Publishing TypeScript libraries |
vite-plugin-svgr |
Imports SVGs as React components | React apps using SVGs as components |
rollup-plugin-visualizer |
Bundle treemap/sunburst report | Periodic bundle size audits (use enforce: 'post') |
vite-plugin-pwa |
Zero-config PWA + Workbox | Offline-capable apps |
Critical callout: vite build transpiles but does NOT type-check. Type errors silently ship to production unless you add vite-plugin-checker or run tsc --noEmit in CI.
Authoring Custom Plugins
Authoring is rare — most needs are covered by existing plugins. When you do need one, start inline in vite.config.ts and only extract if reused.
// vite.config.ts — minimal inline plugin
function myPlugin(): Plugin {
return {
name: 'my-plugin', // required, must be unique
enforce: 'pre', // 'pre' | 'post' (optional)
…
FAQ
What is HMR?
HMR (Hot Module Replacement) updates parts of your code in real-time in the browser without a full page reload, making development faster.
Why use plugins in Vite?
Plugins extend Vite's functionality, allowing you to add features like React or Vue support, image optimization, or PWA (Progressive Web Apps) integration.
How does Vite handle environment variables?
Environment variables prefixed with `VITE_` are included in your project's code for frontend use. Other variables are not exposed for security reasons.
Details
Original description by the author
Vite build tool patterns including config, plugins, HMR, env variables, proxy setup, SSR, library mode, dependency pre-bundling, and build optimization. Activate when working with vite.config.ts, Vite plugins, or Vite-based projects.
repo: affaan-m/ECC
Popularity
- GitHub stars
- 280k
- Ranking position
- #131
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
accessibility
Helps your agent create interfaces that everyone can use. Ensures websites and apps work well for people with disabilities, like those who are blind or have reduced mobility.
affaan-m/ECC
agent-architecture-audit
Makes your agent check if everything is working correctly. It finds and fixes problems in AI systems, ensuring they perform as expected.
affaan-m/ECC
agent-eval
Helps your agent compare different AI coding tools. It measures which one is faster, cheaper, and more reliable for specific tasks.
affaan-m/ECC
agent-harness-construction
Makes your agent better understand how to perform tasks. It optimizes the tools and instructions the agent uses to increase its chances of success.
affaan-m/ECC
Similar skills
web-artifacts-builder
Helps your agent build complex HTML artifacts using modern technologies. Ideal for interfaces with state management and advanced components.
anthropics/skills
frontend-ui-engineering
Helps your agent build beautiful and easy-to-use user interfaces. Makes the output look professional and work well on different devices.
addyosmani/agent-skills
export-nextjs-handoff
Makes your agent turn designs into Next.js code. It creates components, styles, and notes to help the developer.
nexu-io/open-design