plugins/smedjen/skills/vite-patterns/SKILL.md
Vite configuration, plugins, HMR, build optimization, and environment variables.
npx skillsauth add hjemmesidekongen/ai vite-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Vite's two-phase architecture (dev server via native ESM, production build via Rollup) means the rules for dev and prod differ. Configure them independently.
vite.config.ts is the single source of truth. Use defineConfig() for type safety. Split large configs with helper functions rather than a single deeply nested object. Conditional logic based on mode or command goes at the top level, not scattered through the config.
Plugins run in order — transform plugins that produce virtual modules should come before plugins that consume them. Use enforce: 'pre' or enforce: 'post' only when ordering matters and you can't control it via position.
The plugin API (resolveId, load, transform) mirrors Rollup's. Vite-specific additions: configureServer for dev middleware, transformIndexHtml for HTML injection, handleHotUpdate for custom HMR.
For framework integrations, use official plugins: @vitejs/plugin-react, @vitejs/plugin-vue, @vitejs/plugin-svelte. Prefer official over community alternatives for core framework support — the APIs differ subtly.
Only VITE_-prefixed variables are injected into client bundles via import.meta.env. All other .env variables stay server-side. Use .env.local for secrets — it is gitignored by default.
Mode determines which .env file loads: development → .env.development, production → .env.production. Override with --mode staging.
Production builds go through Rollup. Code splitting is automatic for dynamic imports. Manual chunk grouping via build.rollupOptions.output.manualChunks controls vendor bundle structure — use it to isolate large deps and improve long-term caching.
Tree shaking works at the module graph level. Side-effect-free packages need "sideEffects": false in their package.json. For internal code, avoid barrel re-exports that import more than needed.
See references/process.md for full API details, proxy config, CSS handling, library mode, SSR, optimizeDeps, multi-page apps, worker support, and anti-patterns.
development
Creates a brand from scratch through market research and interactive sparring. Runs competitive research via Perplexity, then guides the user through positioning, audience, voice, values, and content pillars. Produces the full brand guideline set at .ai/brand/{name}/. Use when building a new brand, defining brand strategy for a product, or when /våbenskjold:create is invoked.
testing
Loads brand guidelines from .ai/brand/{name}/ and makes them available to the current context. Progressive disclosure: L1 confirms brand exists, L2 loads summary, L3 loads specific files on demand. Use when a downstream skill or user needs brand context, or when /våbenskjold:apply is invoked.
documentation
Guided reinvention of an existing brand guideline. Loads current brand from .ai/brand/{name}/, identifies what to keep vs change, and walks the user through targeted evolution. Preserves brand equity while updating positioning, voice, or values. Use when refreshing a brand or when /våbenskjold:evolve is invoked.
development
Codifies an existing brand from materials, samples, and references. Analyzes provided content to extract voice patterns, values, and positioning. Produces the same guideline format as brand-strategy. Use when a brand already exists but isn't documented, or when /våbenskjold:audit is invoked.