Loading...
Loading...
Vite build tool configuration, plugin API, SSR, library mode, and Vite 8 Rolldown/Oxc migration. Use when working with Vite projects, vite.config.ts, Vite plugins, building libraries or SSR apps with Vite, migrating from older Vite versions, or configuring Rolldown/Oxc options. Also use when the user mentions HMR, import.meta.glob, virtual modules, or Vite environment variables.
npx skill4agent add biggora/claude-plugins-registry vite-best-practicesBased on Vite 8.0 stable (March 2026). Vite 8 uses Rolldown bundler and Oxc transformer, replacing esbuild + Rollup.
esbuildrollupOptions| Deprecated (still works) | Replacement |
|---|---|
| |
| |
| |
| |
vite.config.tsimport.meta.dirname__dirnamerolldownOptionsrollupOptionsoxcesbuild| Topic | Description | Reference |
|---|---|---|
| Configuration | | core-config |
| Features | | core-features |
| Plugin API | Vite/Rolldown hooks, virtual modules, hook filters, plugin ordering | core-plugin-api |
| Topic | Description | Reference |
|---|---|---|
| Build & SSR | Library mode, SSR middleware, | build-and-ssr |
| Topic | Description | Reference |
|---|---|---|
| Environment API | Vite 6+ multi-environment support, custom runtimes | environment-api |
| Rolldown Migration | Vite 8 migration: complete esbuild→oxc and rollupOptions→rolldownOptions mapping, breaking changes | rolldown-migration |
vite # Start dev server
vite build # Production build
vite preview # Preview production build
vite build --ssr # SSR buildimport { defineConfig } from 'vite'
export default defineConfig({
plugins: [],
resolve: {
alias: { '@': '/src' },
tsconfigPaths: true, // New in v8: auto-resolve TS path aliases
},
server: {
port: 3000,
proxy: { '/api': 'http://localhost:8080' },
forwardConsole: true, // New in v8: browser logs → terminal
},
build: {
target: 'esnext',
outDir: 'dist',
rolldownOptions: {}, // NOT rollupOptions
},
oxc: { // NOT esbuild
jsx: {
runtime: 'automatic',
importSource: 'react',
},
},
})@vitejs/plugin-react@vitejs/plugin-react-swc@vitejs/plugin-vue@vitejs/plugin-vue-jsx@vitejs/plugin-legacy// React (automatic runtime — default)
oxc: { jsx: { runtime: 'automatic', importSource: 'react' } }
// Preact (automatic)
oxc: { jsx: { runtime: 'automatic', importSource: 'preact' } }
// Preact (classic with h/Fragment)
oxc: { jsx: { runtime: 'classic', pragma: 'h', pragmaFrag: 'Fragment' } }
// Auto-inject React import (legacy patterns)
oxc: { jsxInject: `import React from 'react'` }