vite-patterns
यह क्या करती है
यह skill आपको Vite को कॉन्फ़िगर और optimize करने में मदद करती है। Vite वेब प्रोजेक्ट बनाने का एक टूल है। यह बताती है कि Vite कैसे काम करता है, उसकी settings कैसे बदलें, और प्लगइन से नए फीचर कैसे जोड़ें।
कब इस्तेमाल करें
- ✓जब `vite.config.ts` फ़ाइल कॉन्फ़िगर करनी हो।
- ✓जब प्रोडक्शन के लिए Vite प्रोजेक्ट तैयार करने का तरीका बदलना हो।
- ✓जब डेवलपमेंट सर्वर या बिल्ड प्रक्रिया में दिक्कत आ रही हो।
Skill का लिंक
https://github.com/affaan-m/ECC/blob/main/pi/core/skills/vite-patterns/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं Vite को API proxy इस्तेमाल करने के लिए कैसे कॉन्फ़िगर करूँ?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
Vite एक तेज़ डेवलपमेंट सर्वर इस्तेमाल करता है जो कोड को ज़रूरत पड़ने पर बदलता है। प्रोडक्शन के लिए यह Rollup या Rolldown जैसे टूल से कोड को बंडल करता है, जिससे आकार और परफ़ॉर्मेंस बेहतर होती है। यह शुरुआत तेज़ करने के लिए dependencies को पहले से बंडल भी कर लेता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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)
…
अक्सर पूछे जाने वाले सवाल
HMR क्या है?
HMR (Hot Module Replacement) ब्राउज़र में पूरा पेज रीलोड किए बिना कोड के हिस्सों को तुरंत अपडेट करता है, जिससे डेवलपमेंट तेज़ होता है।
Vite में प्लगइन क्यों इस्तेमाल करें?
प्लगइन Vite की क्षमता बढ़ाते हैं। इनसे React या Vue सपोर्ट, इमेज ऑप्टिमाइज़ेशन, या PWA (Progressive Web Apps) जैसे फीचर जोड़े जा सकते हैं।
Vite environment variables कैसे संभालता है?
`VITE_` से शुरू होने वाले environment variables फ्रंटएंड कोड में शामिल किए जाते हैं। बाकी variables सुरक्षा कारणों से बाहर नहीं दिखाए जाते।
जानकारी
लेखक का मूल विवरण
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
लोकप्रियता
- GitHub स्टार
- 280k
- रैंकिंग में स्थान
- #256
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
accessibility
280kयह आपके एजेंट को ऐसे इंटरफ़ेस बनाने में मदद करता है जिन्हें हर कोई इस्तेमाल कर सके। यह पक्का करता है कि वेबसाइट और ऐप दिव्यांग लोगों के लिए भी अच्छे से काम करें, जैसे नेत्रहीन या जिन्हें चलने-फिरने में दिक्कत होती है।
agent-architecture-audit
280kयह आपके एजेंट को जाँचने देता है कि सब कुछ सही से चल रहा है। यह AI सिस्टम में समस्याएँ ढूँढकर ठीक करता है, ताकि वे उम्मीद के मुताबिक काम करें।
agent-eval
280kयह आपके एजेंट को अलग-अलग AI coding tools की तुलना करने में मदद करता है। यह मापता है कि किसी खास काम के लिए कौन सा टूल ज़्यादा तेज़, सस्ता और भरोसेमंद है।
agent-harness-construction
280kयह आपके एजेंट को काम कैसे करना है, यह बेहतर समझने में मदद करता है। यह उन tools और instructions को बेहतर बनाता है जिनका एजेंट इस्तेमाल करता है, ताकि उसकी सफलता की संभावना बढ़े।
मिलती-जुलती skills
dream-loop
260kआपके एजेंट को 3D दृश्य या विज़ुअल ऐप के स्क्रीनशॉट को कॉन्सेप्ट आर्ट से मिलाकर बार-बार सुधारते हुए उच्च ग्राफ़िकल गुणवत्ता की ओर ले जाने देती है।
pretext
260kब्राउज़र के ऐसे खेल-भरे डेमो बनाती है जहां टेक्स्ट चलती आकृतियों के चारों ओर बहता है, गेम लेवल बनाता है, या कणों में टूट जाता है।
page-agent
260kआपके एजेंट को वेब ऐप में अंतर्निहित AI सहायक जोड़ने में मदद करती है, ताकि उपयोगकर्ता सादी भाषा में आदेश दे सकें, जिन्हें पेज पूरा करे।