vite
Installation
SKILL.md
Vite
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
Related skills