
Vite Patterns
Configure Vite dev server, env vars, proxies, plugins, library mode, and production builds without fighting HMR or pre-bundling.
Overview
Vite-patterns is an agent skill for the Build phase that guides Vite configuration, dev server behavior, pre-bundling, and production build optimization.
Install
npx skills add https://github.com/affaan-m/everything-claude-code --skill vite-patternsWhat is this skill?
- Covers Vite 8+ config, plugins, HMR, env variables, dev proxy, SSR, and library mode
- Explains dev (native ESM on-demand) vs build (Rolldown v7+ / Rollup v5–v6 bundling)
- Dependency pre-bundling via esbuild with cache under node_modules/.vite
- Troubleshooting CJS/ESM interop, plugin ordering, chunk splits, and minification (Oxc)
- Activation tied to vite.config.ts/js and Vite-based project errors
- Documents Vite 8+ with Rolldown (v7+) or Rollup (v5–v6) for production builds
- Pre-bundling cache path: node_modules/.vite
Adoption & trust: 1.2k installs on skills.sh; 210k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Vite app breaks on env vars, proxy setup, CJS dependencies, or production chunks and you need coherent config and plugin patterns.
Who is it for?
Solo builders on Vite 5+ or 8+ SPAs or component libraries who own vite.config.ts end to end.
Skip if: Teams on Webpack-only or framework-managed zero-config pipelines where Vite is not in the stack.
When should I use this skill?
Working with vite.config.ts, Vite plugins, env/proxy setup, library mode, pre-bundling, HMR, or build errors in Vite-based projects.
What do I get? / Deliverables
You get actionable vite.config guidance for dev proxy, env handling, library mode, and optimized build output with fewer HMR and pre-bundle surprises.
- vite.config recommendations
- Env and proxy setup notes
- Build/library mode configuration outline
Recommended Skills
Journey fit
Vite patterns belong in Build because they govern how frontend source is served, bundled, and optimized before release. Frontend is the shelf: vite.config, HMR, chunks, and `.env` handling are day-to-day UI toolchain work.
How it compares
Focused Vite toolchain patterns—not a full UI framework skill or a CI deploy playbook.
Common Questions / FAQ
Who is vite-patterns for?
Frontend-focused solo devs and indie teams standardizing on Vite for local dev, API proxying, and production bundles.
When should I use vite-patterns?
While configuring vite.config, .env files, dev proxies, library builds, or fixing HMR, pre-bundling, and production chunk issues during Build—and when tuning bundle output before Ship.
Is vite-patterns safe to install?
It is documentation-style; builds still run locally with filesystem and network access—review the Security Audits panel on this page.
SKILL.md
READMESKILL.md - Vite Patterns
# 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 - 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 ```typescript // 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 ```typescript // 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/