/vite:vitefrom vite
Configures and debugs Vite 7 and 8 (Rolldown/Oxc): env variables and client-bundle exposure, dev vs build vs preview, chunking, library mode, SSR externals, pre-bundling, proxy and container access. Use when editing vite.config.*, when a build differs from dev, an env value is missing or leaked, chunks go stale after a deploy, or the dev server is slow.
Ships in vite. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill owns build and dev-server configuration. Framework code belongs to the framework skill: react or vue (if installed). Module-format semantics are out of scope.
package.json, the lockfile, and vite.config.*. Run npx vite --version (or the project's script) and note the framework plugin and its version.^20.19.0 || >=22.12.0. Option names differ between them, so look up each option for the installed major at https://vite.dev/config/ (or the Context7 MCP tools, if available) before using it. Keep both majors working when the repo has not upgraded.build.rollupOptions to build.rolldownOptions, worker.rollupOptions to worker.rolldownOptions, optimizeDeps.esbuildOptions to optimizeDeps.rolldownOptions, and esbuild.* to oxc.*. The old names are deprecated but still work through automatic conversion, so do not rewrite them unless the task is the upgrade (https://vite.dev/guide/migration).default import from a CommonJS module the same way in dev and build. Code that relied on the old split behavior can break after the upgrade. legacy.inconsistentCjsInterop: true restores it temporarily while the import is fixed.vite build for build config, then vite build && vite preview to smoke-test the bundle. A dev-server run alone does not prove the production build works.vite build bundles for production with tree-shaking, splitting, and minification. A library that works in dev can fail in the build, mostly through CommonJS interop. Reproduce with the build, not the dev server.vite preview serves the built output locally. It is a smoke test, not a production server. Deploy dist/ to a static host or a server that sets proper cache headers.tsc --noEmit (or vue-tsc --noEmit for Vue) in CI and before release. vite-plugin-checker can show errors in the dev overlay..env, .env.local, .env.[mode], and .env.[mode].local. Variables already in the process environment win, then mode-specific files, then the generic ones. Add .env.local and .env.*.local to .gitignore.VITE_ reach client code through import.meta.env. They are inlined into the bundle at build time, so anyone can read them. The prefix keeps accidental exposure down, but it does not protect a secret. Put API tokens, database URLs, and private keys behind a server or edge function, and keep only public values (API base URL, public keys, feature flags) in VITE_ variables (https://vite.dev/guide/env-and-mode).envPrefix to ''. Vite's docs warn that it exposes all environment variables.loadEnv(mode, envDir, prefixes = 'VITE_') reads env files for use in vite.config. Passing '' as the third argument loads every variable, including server secrets. That is safe only if none of them reaches client-visible config. A value copied into define is inlined into the bundle. List the prefixes you need (['VITE_', 'APP_']) and pass each define value deliberately.define replaces identifiers statically. Wrap string values in JSON.stringify.ImportMetaEnv in src/vite-env.d.ts. In HTML, %VITE_NAME% is replaced at build time.NODE_ENV are separate. vite build --mode staging stays a production build unless NODE_ENV is changed.build.target is baseline-widely-available. In Vite 8 that is Chrome and Edge 111, Firefox 114, Safari and iOS 16.4. In Vite 7 it is Chrome and Edge 107, Firefox 104, Safari 16.0. Lower it only for a measured audience need. @vitejs/plugin-legacy adds fallback chunks and polyfills, so add it on evidence, not by default.build.minify defaults to 'oxc' in Vite 8 and 'esbuild' in Vite 7. Vite 8 minifies CSS with Lightning CSS by default. 'esbuild' in Vite 8 is deprecated and needs esbuild installed, and 'terser' needs the terser package installed.build.sourcemap off unless an error tracker needs the maps, because public maps expose the original source. Use 'hidden' when you upload them and do not serve them.manualChunks and deprecated the function form. Use build.rolldownOptions.output.codeSplitting with groups (name, test, priority, minSize) (https://rolldown.rs/reference/OutputOptions.codeSplitting). In Vite 7, build.rollupOptions.output.manualChunks still takes an object or a function. Manual splitting can change module execution order, so test the built app. One chunk per package creates hundreds of small files.base when deploying under a sub-path, and use import.meta.env.BASE_URL for runtime URLs.New builds get new chunk hashes, so a tab opened before the deploy requests files that no longer exist. Vite emits vite:preloadError when a dynamic import fails, so reload the page from that handler (https://vite.dev/guide/build). Serve index.html with Cache-Control: no-cache, and keep the previous assets available for a deploy window.
build.lib takes an entry, formats, and fileName. Single-entry libraries default to es and umd, and multi-entry libraries to es and cjs.
build.rolldownOptions.external, or rollupOptions in Vite 7), including JSX runtime paths such as react/jsx-runtime. A bundled peer causes duplicate-runtime errors in the consumer.tsc --emitDeclarationOnly or a declaration plugin.exports, main, and types fields of package.json against the output files, then install the packed tarball in a scratch project.Most apps should get SSR from a framework (Nuxt, SvelteKit, Astro, TanStack Start) rather than a custom middlewareMode server.
ssr.noExternal (bundle it, which fixes most ESM-only package errors) or ssr.external (keep it as a Node import). ssr.target is 'node' or 'webworker'.--conditions in dev and production when ssr.resolve.externalConditions is set (https://vite.dev/config/ssr-options).server.proxy maps a path to a backend. Add changeOrigin: true for virtual-hosted backends, rewrite to strip a prefix, and ws: true for WebSockets.localhost by default. Set server.host: true (or --host 0.0.0.0) to reach it from outside a container. A hostname other than localhost or an IP address is rejected unless it matches server.allowedHosts. List the host you need, and avoid true because it allows any host. Behind a reverse proxy, set server.hmr.clientPort or the HMR host so the WebSocket connects.server.fs.strict blocks files outside the workspace root. List the directories you need in server.fs.allow. Keep server.fs.deny entries for .env files and keys.server.watch.usePolling where native events fail, such as WSL2 with files on the Windows side or some network mounts.Vite pre-bundles dependencies once to turn CommonJS and UMD into ESM and to collapse packages with many internal modules. The cache lives in node_modules/.vite and is invalidated by lockfile, patch, config, and NODE_ENV changes.
optimizeDeps.include.optimizeDeps.exclude only for a dependency that is already valid ESM. Linked monorepo packages are treated as source by default.vite --force (or deleting node_modules/.vite) rebuilds the cache. Treat it as a diagnostic, not a fix.vite --profile, use the app, press p then Enter, and open the .cpuprofile in Speedscope. vite --debug plugin-transform shows slow transforms. Typical fixes from the performance guide are direct imports instead of barrel files, explicit file extensions, server.warmup.clientFiles for hot entry files, and trimming plugins that do heavy work in buildStart, config, or configResolved (https://vite.dev/guide/performance).Prefer what the framework and the repo already use. Read references/plugins.md when choosing, ordering, or writing a plugin.
State the Vite major and framework plugin versions, the config keys changed and why, and the commands run (vite build, vite preview, tsc --noEmit). Say what the dev-only checks did not cover.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub adminhead/claude-plugins --plugin vite