What does this skill do?

The Vite Skill Templates guide you through the configuration, optimization, and deployment of Vite 8+ projects, covering the development server, HMR, production builds, environment variables, and library mode. It provides robust patterns using `defineConfig`, secure segregation of environment variables, chunk optimization, and dependency externalization for publishing npm packages.

vite.config.ts Configuration
Create conditional configurations using `defineConfig` and `loadEnv` while ensuring type inference.
Safe Environment Variables
Load only variables prefixed with VITE_ and avoid exposing server secrets to the client.
Build and Chunk Optimization
Separate third-party dependencies using manualChunks and improve caching for the production bundle.
npm Library Mode
Outsource peer dependencies and generate ES and CJS formats to publish packages without runtime duplication.

Usage examples

⚙️ Basic Settings
I need to configure `vite.config.ts` with React and secure environment variables for my project.
🔌 API Proxy
Configure a proxy on the Vite development server to redirect /api to localhost:8080.
📦 Chunk Optimization
Optimize the build of my Vite app by splitting React, React-DOM, and Radix UI components into separate chunks.
📚 Publish a bookstore
I want to publish my npm package using Vite in lib mode, generating ES and CJS formats and externalizing React.

Features

Conditional Configuration with Types Use `defineConfig` with type inference and conditional configuration based on `command` and `mode`.
Secure Management of Environment Variables Load variables prefixed with VITE_ using loadEnv, and expose only what is necessary using define.
Development Server Proxy Configure proxies for backend APIs with route rewriting and `changeOrigin`.
Bundle Optimization with manualChunks Split third-party dependencies into separate chunks to improve browser caching.
Bookstore Mode with Externalization Generates npm packages in ES and CJS formats by externalizing peer dependencies to avoid duplication.

Frequently asked questions

Covers Vite 8+ and later, including server configuration, build, HMR, environment variables, and library mode.
No. Vite transpilates but does not perform type checking. You must run `tsc --noEmit` in your CI to ensure type safety.
Use `loadEnv` with a prefix such as `VITE_` to load only safe variables and avoid including server secrets in the client bundle.
Yes. The configuration, proxy, and chunk optimization patterns apply to any Vite project, whether you're using Vue, Svelte, or vanilla JS.
Vite Templates — Advanced Configuration and Optimization with Claude AI

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.