All skills
antfu avatar

/vite

@d02c484 official
by Anthony Fuantfu/skills5.9k stars
335

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.

Use this Skill: https://skilld.dev/gh/antfu/skills/vite

This session only. Nothing lands on disk.

referencesrolldown-migration.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Rolldown Migration (Vite 8)

Vite 8 replaces esbuild + Rollup with Rolldown (Rust bundler) and Oxc (Rust transformer/minifier).

What Changed

Before (Vite 7) After (Vite 8)
esbuild (dev/JS transform) Oxc Transformer
esbuild (dep pre-bundling) Rolldown
esbuild (CSS minify) Lightning CSS (default)
Rollup (production build) Rolldown
build.rollupOptions build.rolldownOptions
worker.rollupOptions worker.rolldownOptions
optimizeDeps.esbuildOptions optimizeDeps.rolldownOptions
esbuild option oxc option

Backward Compatibility (Auto-Conversion)

Old options are deprecated but still work — Vite converts them internally:

  • esbuild → oxc
  • build.rollupOptions → build.rolldownOptions (alias)
  • optimizeDeps.esbuildOptions → optimizeDeps.rolldownOptions

Migrate to the new names; the compat shims will be removed in a future major. Read the converted values from the configResolved hook (config.oxc, config.optimizeDeps.rolldownOptions).

Default Browser Target Change

build.target / 'baseline-widely-available' moved to newer versions (Baseline Widely Available as of 2026-01-01):

  • Chrome 107 → 111, Edge 107 → 111, Firefox 104 → 114, Safari 16.0 → 16.4
  • Resolves to ['chrome111', 'edge111', 'firefox114', 'safari16.4', 'ios16.4']
  • Default --minify is now oxc (was esbuild)

Config Migration

rollupOptions → rolldownOptions

export default defineConfig({
  build: {
    rolldownOptions: {  // was rollupOptions
      external: ['vue'],
      output: { globals: { vue: 'Vue' } },
    },
  },
})

Prefer the top-level input option over build.rolldownOptions.input — it applies in dev too.

esbuild → oxc

export default defineConfig({
  oxc: {  // was esbuild
    jsx: {
      runtime: 'classic',
      pragma: 'h',
      pragmaFrag: 'Fragment',
    },
  },
})

esbuild.jsxFactory→oxc.jsx.pragma, jsxFragment→oxc.jsx.pragmaFrag, jsx: 'transform'→oxc.jsx: { runtime: 'classic' }, jsx: 'automatic'→{ runtime: 'automatic' }. esbuild.banner/footer have no equivalent — use a custom plugin transform hook.

JSX Configuration

export default defineConfig({
  oxc: {
    jsx: {
      runtime: 'automatic',  // or 'classic'
      importSource: 'react', // for automatic runtime
    },
    jsxInject: `import React from 'react'`,  // auto-inject
  },
})

Custom Transform Targets

export default defineConfig({
  oxc: {
    include: ['**/*.ts', '**/*.tsx'],
    exclude: ['node_modules/**'],
  },
})

Notable Breaking Changes

  • build() throws BundleError (JS API): typed Error & { errors?: RolldownError[] }. Access individual errors via e.errors.
  • build.rollupOptions.output.manualChunks: object form removed, function form deprecated. Use Rolldown's codeSplitting.
  • build.rollupOptions.watch.chokidar removed → build.rolldownOptions.watch.watcher.
  • resolve.alias[].customResolver deprecated → use a custom plugin with a resolveId hook and enforce: 'pre'.
  • build.commonjsOptions is now a no-op.
  • require calls for externalized modules are preserved as require. To convert to import, use the re-exported esmExternalRequirePlugin.
  • import.meta.hot.accept(url) no longer accepts a URL — pass an id.
  • Unsupported by Rolldown: output format 'system'/'amd', shouldTransformCachedModule, resolveImportMeta, renderDynamicImport, resolveFileUrl hooks.
  • Native decorator lowering is not yet supported by Oxc — use @rolldown/plugin-babel or @rollup/plugin-swc as a workaround.

Detecting Rolldown-powered Vite

buildStart() {
  // only defined on Vite 8+ (Rolldown)
  if (this.meta.rolldownVersion) { /* ... */ }
}

Also exported from vite: version, rolldownVersion (esbuildVersion/rollupVersion kept only for back-compat).

Plugin Compatibility

Most Vite plugins work unchanged — Rolldown supports Rollup's plugin API. Rolldown runs all parallel Rollup hooks sequentially. If a plugin only works during build:

{
  ...rollupPlugin(),
  enforce: 'post',
  apply: 'build',
}

New Capabilities

  • Full bundle mode (experimental, vite --experimentalBundle)
  • Chunk import map optimization (build.chunkImportMap)
  • More flexible chunk splitting / Module Federation support

Gradual Migration

rolldown-vite is Vite 7 running on Rolldown without other Vite 8 changes — an intermediate step:

# Step 1: swap vite for rolldown-vite on Vite 7 (npm alias in package.json)
#   "vite": "npm:rolldown-vite@^7"
# Step 2: undo the alias and upgrade to Vite 8
pnpm add -D vite@8

If migrating from rolldown-vite, only the "NRV"-badged sections of the official migration guide apply.

Overriding Vite in Frameworks

When a framework depends on older Vite:

{
  "pnpm": {
    "overrides": {
      "vite": "8.0.0"
    }
  }
}
<!-- Source references: - https://vite.dev/guide/migration - https://vite.dev/blog/announcing-vite8 - https://vite.dev/config/shared-options#oxc -->

Source: SKILL.md on GitHub

No alerts3d5 checks · Risk SAFE
  • Gen Agent Trust Hub3d

    This skill provides comprehensive documentation and reference material for the Vite build tool, including Vite 8 migration guidance, plugin API details, and server-side rendering configurations. No security issues were detected.

  • Socket3d

    No alerts

  • Snyk3d

    Risk: LOW · No issues

  • Runlayer6mo

    1/8 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at d02c484. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 4 days ago
Other metadata
metadata
{
  "author": "Anthony Fu",
  "version": "2026.9.25",
  "source": "Generated from https://github.com/vitejs/vite, scripts at https://github.com/antfu/skills"
}

README badge

README badge for antfu/skills/vite

Vite is a next-generation frontend build tool with a fast dev server using native ESM and HMR, optimized production builds, and Vite 8 support for Rolldown-powered bundling. Use this skill when configuring vite.config.ts, developing Vite plugins, or building libraries and SSR applications.

Generated from the current SKILL.md.

Does this skill cover Vite 8 and Rolldown?
Yes. The skill is based on Vite 8 beta and includes migration guidance for Rolldown bundler and Oxc transformer changes.
What does this skill help with?
Configuration (vite.config.ts), plugin API, asset imports, SSR setup, library mode, and Vite 8 migration patterns.
Does this cover framework-specific setups like React or Vue?
The skill documents official plugins like @vitejs/plugin-react and @vitejs/plugin-vue, but focuses on core Vite configuration and APIs, not framework-specific best practices.
Is CommonJS supported?
No. The skill prefers ESM and encourages avoiding CommonJS in Vite projects.

Generated from the current SKILL.md. These answers refresh after source changes.