Skip to main content
skill CX Codex

vite · oakoss — Claude Code skill: Vite config, build and SSR

A skill for Vite work: config file, plugins, dev server, build output, SSR and env variables. Useful when the agent edits vite.config.ts in your project.

MIT 138 installs ★ 29 updated 2026-08-17

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add oakoss/agent-skills --skill vite -a claude-code
Open on GitHub

What vite does

The skill maps how Vite is put together: defineConfig as a function of command and mode, aliases in resolve.alias, proxy and HMR under server, the output standard in build.target, splitting through manualChunks. Library publishing with build.lib, SSR with build.ssr, env handling via import.meta.env.VITE_* and loadEnv, plus CSS modules, preprocessors and static assets.

One SKILL.md holds two tables: a pattern lookup and a list of common mistakes. The rest sits in references/, split by topic — config, plugins, dev server, build optimization, library mode, SSR, env files, CSS and assets. Test setup is handed to vitest-testing and Tailwind work to tailwind when those skills are present.

Watch the library case: peer dependencies left out of rollupOptions.external get bundled into the package you publish, so React or Vue ships twice for anyone who installs it. Secrets are the other trap. A VITE_ prefix pushes a value into the browser bundle, which is why server-side values belong in loadEnv inside the config.

What it helps with

  • Set up a dev-server proxy so API calls reach the backend
  • Split the bundle into chunks with manualChunks
  • Publish a library in ES and CJS without React inside
  • Find out why an .env value never reaches the browser
  • Wire SSR builds without leaking state between requests

Example prompts for the agent

  • Add an @/ alias to src/ and proxy /api to the backend in vite.config.ts
  • Build this as a library with build.lib and keep React in rollupOptions.external
  • Set up manualChunks so vendor code lands in its own chunk

How to install vite

1Skills CLI (Vercel)

npx skills add oakoss/agent-skills --skill vite -a claude-code

2Manually: put the files in place

~/.claude/skills/vite/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/vite/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about vite

How do I install the vite skill in Claude Code?

Run npx skills add oakoss/agent-skills --skill vite -a claude-code. The skill lands at ~/.claude/skills/vite/SKILL.md.

What does the vite skill do?

It gives the agent a reference for vite.config.ts: plugins, dev server, build output, library mode, SSR, env variables, CSS and assets. A table of common config mistakes comes with it.

When is Vite a bad fit?

Projects that need ES5 output for old browsers without a transpile step, setups tied to webpack loaders that have no Vite counterpart, or build pipelines that are not about JavaScript.

Source text

SKILL.md · MIT
---
name: vite
description: |
  Vite build tool configuration and ecosystem. Covers vite.config.ts setup, plugin authoring and popular plugins, dev server configuration (proxy, HMR, HTTPS), build optimization (chunking, tree-shaking, manual chunks, rollupOptions), library mode for publishing packages, SSR configuration, environment variables (.env handling), multi-page apps, CSS handling (PostCSS, CSS modules, preprocessors), and asset handling.

  Use when configuring Vite projects, authoring Vite plugins, optimizing builds, setting up dev server proxies, configuring SSR, handling environment variables, or troubleshooting Vite issues.
license: MIT
metadata:
  author: oakoss
  version: '1.0'
  source: 'https://vite.dev/guide/'
user-invocable: false
---

# Vite

## Overview

Vite is a next-generation frontend build tool that provides instant dev server start via native ES modules and optimized production builds via Rollup. It supports TypeScript, JSX, CSS preprocessors, and static assets out of the box with zero configuration.

**When to use:** Single-page apps, multi-page apps, library publishing, SSR applications, monorepo packages, any modern frontend project needing fast dev feedback and optimized builds.

**When NOT to use:** Legacy browsers requiring ES5 output without transpilation, projects locked to Webpack-specific loaders with no Vite equivalents, non-JavaScript build pipelines.

## Quick Reference

| Pattern            | API                                         | Key Points                        |
| ------------------ | ------------------------------------------- | --------------------------------- |
| Config file        | `defineConfig({})`                          | Type-safe config with IDE support |
| Conditional config | `defineConfig(({ command, mode }) => ({}))` | Different config per command/mode |
| Path alias         | `resolve.alias`                             | Map `@/` to `src/`                |
| Dev proxy          | `server.proxy`                              | Forward API requests to backend   |
| HMR config         | `server.hmr`                                | WebSocket host/port/protocol      |
| HTTPS dev          | `server.https`                              | Pass TLS cert/key options         |
| Build target       | `build.target`                              | ES module target for output       |
| Manual chunks      | `build.rollupOptions.output.manualChunks`   | Control code splitting            |
| Library mode       | `build.lib`                                 | Publish ES/CJS/UMD packages       |
| SSR build          | `build.ssr` + `ssr` options                 | Server-side rendering config      |
| Env variables      | `import.meta.env.VITE_*`                    | Client-exposed env vars           |
| loadEnv            | `loadEnv(mode, root, prefix)`               | Load env vars in config           |
| CSS modules        | `css.modules`                               | Scoped CSS class names            |
| Preprocessors      | `css.preprocessorOptions`                   | Sass/Less/Stylus options          |
| PostCSS            | `css.postcss`                               | Inline or external PostCSS config |
| Static assets      | `import url from './img.png'`               | Returns resolved public URL       |
| Plugin             | `{ name, transform, load }`                 | Hook-based plugin system          |
| Virtual module     | `resolveId` + `load` hooks                  | Generate modules at build time    |
| Multi-page         | `build.rollupOptions.input`                 | Multiple HTML entry points        |

## Common Mistakes

| Mistake                                             | Correct Pattern                                                                            |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| Exposing secrets via `VITE_` prefix                 | Only prefix client-safe vars with `VITE_`; use `loadEnv` in config for server-only secrets |
| Using `process.env` in client code                  | Use `import.meta.env.VITE_*` (Vite replaces at build time)                                 |
| Modifying `rollupOptions.input` without `resolve()` | Always use `path.resolve()` or `import.meta.dirname` for absolute paths                    |
| Not externalizing peer deps in library mode         | Add React/Vue to `rollupOptions.external` to avoid bundling                                |
| Creating QueryClient-style singletons in SSR        | Ensure per-request state in SSR to avoid cross-request leaks                               |
| Inline PostCSS config alongside `postcss.config.js` | Use one or the other; inline config disables config file search                            |
| Setting `base` without trailing slash               | `base` should be `/path/` with trailing slash or full URL                                  |
| Using `__dirname` in ESM config                     | Use `import.meta.dirname` (Node 21+) or `fileURLToPath`                                    |

## Delegation

- **Plugin discovery**: Use `Explore` agent
- **Build analysis**: Use `Task` agent
- **Config review**: Delegate to `code-reviewer` agent

> If the `vitest-testing` skill is available, delegate test configuration and Vitest setup to it.
> If the `tailwind` skill is available, delegate Tailwind CSS configuration and utility patterns to it.
> If the `react-patterns` skill is available, delegate React component patterns and hooks to it.
> If the `typescript-patterns` skill is available, delegate TypeScript configuration and type patterns to it.
> If the `pnpm-workspace` skill is available, delegate monorepo workspace configuration to it.

## References

- [Configuration fundamentals and defineConfig patterns](references/configuration.md)
- [Plugin authoring and popular plugins](references/plugins.md)
- [Dev server setup: proxy, HMR, HTTPS, and middleware](references/dev-server.md)
- [Build optimization: chunking, tree-shaking, and output control](references/build-optimization.md)
- [Library mode for publishing packages](references/library-mode.md)
- [SSR configuration and Express integration](references/ssr-configuration.md)
- [Environment variables and .env file handling](references/environment-variables.md)
- [CSS handling: PostCSS, CSS modules, preprocessors, and asset management](references/css-and-assets.md)

© oakoss · MIT · oakoss/agent-skills

Similar skills

All skills for Frontend and UI →

vite by other authors comes first.

vite Anthony Fu A skill for Claude Code and Codex covers Vite configuration, plugins, SSR, and library builds. It guides work on vite.config.ts and Vite 8 migration. CX Codex +1 42,400installs vite Mindrally Supplies your coding agent with vetted Vite recipes for HMR, chunk splitting, framework plugins, and Vitest setups. CX Codex +1 875installs vite pproenca A performance optimization guide with 42 Vite rules. Helps your AI agent audit configs, optimize bundles, and fix slow dev servers. CX Codex +1 376installs vite itechmeat This skill guides an agent through Vite setup, builds, plugins, HMR, and environment settings when a project needs frontend tooling support. CX Codex +1 111installs vite-bundle-optimization patterns.dev vite-bundle-optimization is a skill for Claude Code, Codex, Cursor, GitHub Copilot, and Gemini CLI for Vite + React bundle optimization. It activates during build configuration, code splitting, or slow-build diagnosis. CX Codex +1 692installs vinext-vite-nextjs reason-machines vinext-vite-nextjs guides your AI assistant through running Next.js codebases on Vite and deploying them to Cloudflare Workers. CX Codex +1 1,400installs vite-advanced OrchestKit vite-advanced is a Claude Code and Codex skill for Vite 8 builds with Rolldown, chunk splitting, and Environment API. It activates when editing vite.config.* or files under **/vite/**. CX Codex +1 265installs vite-patterns affaan-m The vite-patterns skill guides Vite configuration, plugins, HMR, environment variables, and builds. Use it when working with vite.config.ts or a Vite project. CX Codex +1 6,500installs vite-react-best-practices ant-gravity vite-react-best-practices guides coding agents through deployment, routing, and caching rules for React 19 and Vite 8 SPAs. Triggers during project setup, CI/CD builds, or component refactoring. CX Codex +1 670installs react-vite-best-practices agent-skills react-vite-best-practices — a skill with 23 rules for optimizing React apps built with Vite: build config, code splitting, HMR, assets, env variables and bundle analysis. Useful when an agent writes or reviews components. CX Codex +1 3,000installs

From the same set106

The whole set →
hydration-guardian hydration-guardian finds where server-rendered HTML and the client React tree disagree, then points to the pattern that fixes it. CX Codex +1 144installs e2e-testing e2e-testing guides AI coding assistants on Playwright E2E test suite architecture, Page Object Models, network mocking, and CI sharding strategies. CX Codex +1 142installs valkey This skill guides Valkey setup for caching, rate limits, queues, and Redis migration. Use it when choosing data patterns or configuring a Docker Compose service. CX Codex +1 142installs remotion A rulebook for Remotion: your agent builds video out of React components and keeps animation tied to the timeline instead of CSS. CX Codex +1 141installs postgres-tuning postgres-tuning — a skill for Claude Code, Codex, Cursor and other agents that provides PostgreSQL 17/18+ performance tuning guidance. Covers async I/O, query plan forensics, index strategy, autovacuum, pgvector, and connection pooling. CX Codex +1 136installs tanstack-db Get guidance on TanStack DB collections, live queries, and optimistic writes. Useful when a UI needs reactive local data or explicit sync with a backend. CX Codex +1 136installs prompt-engineering prompt-engineering is a Claude Code skill for prompt design, covering reasoning chains, ReAct loops, system prompt layouts, extended thinking and context trimming. CX Codex +1 135installs react-error-handling react-error-handling guides agents on React error boundaries and fallback interfaces to prevent component rendering failures from crashing the whole page. CX Codex +1 134installs

Project sponsors

Companies that keep this analytics open