vite
Assists with configuring and using Vite as a frontend build tool for modern web applications. Use when setting up dev servers, optimizing production builds, configuring plugins, migrating from Webpack or CRA, or building component libraries. Trigger words: vite, build tool, HMR, hot module replacement, vite config, rollup, bundling.
Usage
Getting Started
- Install the skill using the command above
- Open your AI coding agent (Claude Code, Codex, Gemini CLI, or Cursor)
- Reference the skill in your prompt
- The AI will use the skill's capabilities automatically
Example Prompts
- "Review the open pull requests and summarize what needs attention"
- "Generate a changelog from the last 20 commits on the main branch"
Documentation
Overview
Vite is a next-generation frontend build tool providing instant dev server startup via native ES modules and optimized Rollup-based production builds. It supports React, Vue, Svelte, and vanilla TypeScript projects with advanced bundling strategies, plugin extensibility, and library mode.
Instructions
- When setting up a project, create
vite.config.tswith the appropriate framework plugin (@vitejs/plugin-react,@vitejs/plugin-vue), configureresolve.aliaswith@mapping tosrc/, and set environment variables withVITE_prefix. - When configuring the dev server, set up API proxying with
server.proxy, enable HTTPS with@vitejs/plugin-basic-ssl, and useserver.watchpolling for containers or VMs. - When optimizing builds, configure manual chunks with
build.rollupOptions.output.manualChunksfor vendor splitting, enable CSS code splitting, and setbuild.targetfor browser compatibility. - When creating plugins, use the Rollup-compatible plugin API with
resolveId,load, andtransformhooks, and leverage virtual modules with thevirtual:prefix. - When building libraries, configure
build.libwith entry point and output formats (es, cjs, umd), externalize peer dependencies, and usevite-plugin-dtsfor TypeScript declaration generation. - When migrating from Webpack, replace
webpack.config.jswithvite.config.ts, swap loaders for Vite plugins, and updateREACT_APP_*env vars toVITE_*. - When integrating testing, use Vitest which shares Vite config and provides instant HMR for tests.
Examples
Example 1: Migrate a Create React App project to Vite
User request: "Convert my CRA project to use Vite instead"
Actions:
- Install Vite and
@vitejs/plugin-react, remove react-scripts - Create
vite.config.tswith React plugin and path aliases - Rename
REACT_APP_*environment variables toVITE_* - Update
index.htmlto reference the entry module directly
Output: A Vite-powered React project with faster dev startup and HMR.
Example 2: Configure optimized production build
User request: "Set up Vite build with vendor chunk splitting and source maps for Sentry"
Actions:
- Configure
build.rollupOptions.output.manualChunksto separate vendor libraries - Enable
build.sourcemapfor error monitoring integration - Set
build.targetappropriate to browser support requirements - Add
build.assetsInlineLimittuning for small asset optimization
Output: An optimized production build configuration with proper chunk splitting and debugging support.
Guidelines
- Always use
import.meta.env.VITE_*for client-exposed env vars, neverprocess.env. - Configure
resolve.aliaswith@prefix mapping tosrc/for clean imports. - Split vendor chunks manually when default chunking produces too many small files.
- Use
build.target: "esnext"for modern-only apps,@vitejs/plugin-legacyfor legacy browser support. - Enable
build.sourcemapin production for error monitoring tools. - Keep
vite.config.tsclean by extracting complex plugin configs into separate files. - Use
optimizeDeps.includeto pre-bundle problematic dependencies that break during dev.
Information
- Version
- 1.0.0
- Author
- terminal-skills
- Category
- Development
- License
- Apache-2.0