Generated banner for Vite
Generated logo for Vite

Vite

Anthony FuCommunityCreated by Anthony Fu

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

Vite build tool configuration, plugin API, SSR, and Vite 8 Rolldown migration. Use when working with Vite projects, vite.config.ts, Vite plugins, or building libraries/SSR apps with Vite.
— the description by Anthony Fu

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides comprehensive reference material for Vite 8, a frontend build tool that utilizes the Rolldown bundler and Oxc transformer. It covers core configuration patterns, the plugin API, library mode, and SSR primitives. It also includes specific guidance for migrating to Vite 8, managing multi-environment setups, and utilizing the JavaScript API for programmatic control over build and development processes.

What it does

  • Provides patterns for vite.config.ts including conditional and asynchronous configurations.
  • Explains the Rolldown migration process for Vite 8 projects.
  • Details the Vite plugin API for creating custom hooks and virtual modules.
  • Offers guidance on library mode, SSR middleware, and multi-page application setups.
  • Documents the JavaScript API for programmatic server creation and build execution.
  • Lists official plugins for framework support including Vue and React.

When to use it

  • When configuring a new or existing Vite 8 project.
  • When migrating a project from previous Vite versions to Vite 8.
  • When building libraries or SSR applications using Vite primitives.
  • When developing custom Vite plugins or integrating multi-environment support.
  • When needing to programmatically control the Vite build or dev server via the JavaScript API.

Advantages

  • Centralized reference for Vite 8 specific changes like Rolldown and Oxc.
  • Clear examples for complex configurations like proxying and environment variables.
  • Provides structured guidance for library distribution and multi-page entry points.
  • Includes TypeScript intellisense patterns for configuration files.

Usage examples

“How do I configure a proxy in my vite.config.ts?”
The skill provides a code snippet showing the server.proxy configuration object with target, changeOrigin, and path rewrite options.
“Show me how to set up a library build in Vite 8.”
The skill provides a configuration example using the build.lib option, including entry points and rolldownOptions for external dependencies.
“How do I access environment variables inside my Vite config?”
The skill demonstrates using the loadEnv function within a defineConfig function to access variables from .env files during configuration resolution.
“What is the new way to define entry points in Vite 8?”
The skill explains the top-level input option which replaces previous entry point configurations for build, SSR, and dependency optimization.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/antfu/vite/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip vite.zip -d .agents/skills

Documentation by Anthony Fu

Vite

Based on Vite v8.3.5 (Rolldown-powered), generated at 2026-11-05. Vite 8 uses the Rolldown bundler and the Oxc transformer instead of esbuild + Rollup.

Vite is a next-generation frontend build tool with fast dev server (native ESM + HMR) and optimized production builds.

Preferences

  • Use TypeScript: prefer vite.config.ts

  • Always use ESM, avoid CommonJS

Core

TopicDescriptionReference
Configurationvite.config.ts, defineConfig, conditional configs, loadEnvcore-config
Featuresimport.meta.glob, asset queries (?raw, ?url), import.meta.env, HMR APIcore-features
Plugin APIVite-specific hooks, virtual modules, plugin orderingcore-plugin-api

Build & SSR

TopicDescriptionReference
Build & SSRLibrary mode, SSR middleware mode, ssrLoadModule, JavaScript APIbuild-and-ssr

Advanced

TopicDescriptionReference
Environment APIVite 6+ multi-environment support, custom runtimesenvironment-api
Rolldown MigrationVite 8 changes: Rolldown bundler, Oxc transformer, config migrationrolldown-migration

Quick Reference

CLI Commands
vite              # Start dev server
vite build        # Production build
vite preview      # Preview production build
vite build --ssr  # SSR build
Common Config
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [],
  resolve: { alias: { '@': '/src' } },
  server: { port: 3000, proxy: { '/api': 'http://localhost:8080' } },
  build: { target: 'esnext', outDir: 'dist' },
})
Official Plugins
  • @vitejs/plugin-vue - Vue 3 SFC support

  • @vitejs/plugin-vue-jsx - Vue 3 JSX

  • @vitejs/plugin-react - React with Oxc/Babel

  • @vitejs/plugin-react-swc - React with SWC

  • @vitejs/plugin-legacy - Legacy browser support

Files

references/environment-api.md


name: vite-environment-api description: Vite 6+ Environment API for multiple runtime environments

Environment API (Vite 6+)

The Environment API formalizes multiple runtime environments beyond the traditional client/SSR split.

Concept

Before Vite 6: Two implicit environments (client and ssr).

Vite 6+: Configure as many environments as needed (browser, node server, edge server, etc.).

Basic Configuration

For SPA/MPA, nothing changes—options apply to the implicit client environment:

export default defineConfig({
  build: { sourcemap: false },
  optimizeDeps: { include: ['lib'] },
})

Multiple Environments

export default defineConfig({
  build: { sourcemap: false },  // Inherited by all environments
  optimizeDeps: { include: ['lib'] },  // Client only
  environments: {
    // SSR environment
    server: {},
    // Edge runtime environment
    edge: {
      resolve: { noExternal: true },
    },
  },
})

Environments inherit top-level config. Some options (like optimizeDeps) only apply to client by default.

Environment Options

interface EnvironmentOptions {
  define?: Record<string, any>
  resolve?: EnvironmentResolveOptions
  optimizeDeps: DepOptimizationOptions
  consumer?: 'client' | 'server'
  dev: DevOptions
  build: BuildOptions
}

Custom Environment Instances

Runtime providers can define custom environments:

import { customEnvironment } from 'vite-environment-provider'

export default defineConfig({
  environments: {
    ssr: customEnvironment({
      build: { outDir: '/dist/ssr' },
    }),
  },
})

Example: Cloudflare's Vite plugin runs code in workerd runtime during development.

Dev Environment Types

Environments run modules through a runner. Two dev environment shapes exist:

  • RunnableDevEnvironment — evaluates modules in the same runtime as the Vite server, so it exchanges arbitrary JS values in-process. Its runner.import(url) is the modern replacement for server.ssrLoadModule (full HMR). Default for ssr and other non-client envs. Guard with isRunnableDevEnvironment(env).

if (isRunnableDevEnvironment(server.environments.ssr)) {
  const mod = await server.environments.ssr.runner.import('/src/entry-server.ts')
}
  • FetchableDevEnvironment — communicates only via the Fetch API (Request/Response), so it works for runtimes that can't run Vite directly (e.g. Cloudflare Workers). Preferred over RunnableDevEnvironment for such runtimes. Handle requests with handleRequest; dispatch via env.dispatchFetch(new Request(url)).

Building Environments

vite build / vite build --ssr still build only client/ssr for back-compat. Setting the builder option (even {}, which is what vite build --app does) opts into building all environments.

import { createBuilder } from 'vite'

const builder = await createBuilder()      // build-time equivalent of createServer
await builder.buildApp()                    // build every configured environment
// await builder.build(builder.environments.ssr) // or one at a time

createBuilder supersedes the standalone build() for environment-aware builds. Customize with the builder.buildApp config option or the global buildApp plugin hook (use environment.isBuilt to skip already-built envs).

Per-Environment Plugins

Restrict a plugin to specific environments with applyToEnvironment, or configure each env with the configEnvironment hook (set defaults in config, since the full env list isn't known there):

{
  name: 'ssr-only',
  applyToEnvironment(env) { return env.name === 'ssr' },
}

Backward Compatibility

  • server.moduleGraph returns mixed client/SSR view

  • ssrLoadModule still works

  • Existing SSR apps work unchanged

When to Use

  • End users: Usually don't need to configure—frameworks handle it

  • Plugin authors: Use for environment-aware transformations

  • Framework authors: Create custom environments for their runtime needs

Plugin Environment Access

Plugins can access environment in hooks:

{
  name: 'env-aware',
  transform(code, id, options) {
    if (options?.ssr) {
      // SSR-specific transform
    }
  },
}

<!-- Source references: - https://vite.dev/guide/api-environment - https://vite.dev/guide/api-environment-frameworks - https://vite.dev/guide/api-environment-plugins - https://vite.dev/guide/api-environment-runtimes - https://vite.dev/blog/announcing-vite6 -->

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
Anthony Fu
Publisher
Anthony Fu (Community)
Source
antfu/skills · skills/vite · commit f63e9ec
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.md)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Anthony Fu.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download vite.zip