agentleFS
socialadsmentorsocialadsmentor/sam-agentic-harness/skills/vite-patterns/SKILL.md

vite-patterns

Skill4 starsChanged 3 months agoMITView on GitHub

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.

  • Reads credentials

4 other projects use a version of this, 3 of them edited.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

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.

Quick Reference

PatternWhen to Use
defineConfigAlways - provides type inference
loadEnv(mode, root, ['VITE_'])Access env vars in config (explicit prefix)
vite-plugin-checkerAny TypeScript app (fills the type-check gap)
vite-tsconfig-pathsInstead of hand-rolled resolve.alias
optimizeDeps.includeCJS deps causing interop issues
server.proxyRoute API requests to backend in dev
server.host: trueDocker, containers, remote access
server.warmup.clientFilesPre-transform hot-path routes
build.lib + externalPublishing npm packages
manualChunks (object)Vendor bundle splitting
vite --profileDebug slow dev server
vite build && vite previewSmoke-test prod bundle locally (NOT a prod server)

Related Skills

  • frontend-patterns - React component patterns
  • docker-patterns - containerized dev with Vite
  • nextjs-turbopack - alternative bundler for Next.js

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.