7.1 · difficulty 2/4 · 16 min read
Rolldown's Role in the Vite 8 Build
How Vite build uses Rolldown, how to configure rolldownOptions, how rollupOptions migration works, and how minification, manifests, and chunk caching fit together.
vite build Is Still a Vite Command
Vite 8 uses Rolldown for production bundling, but vite build is not just raw Rolldown. Vite still:
- loads and merges
vite.config.ts - loads mode and
.envfiles - creates the plugin container and Vite core plugins
- turns HTML, CSS, assets, workers, and WASM into bundler inputs
- calls Rolldown to emit chunks and assets
- emits Vite-level outputs such as manifests and license files
Think in two layers:
| Layer | Config entry | Examples |
|---|---|---|
| Vite build semantics | build.* | outDir, target, manifest, minify |
| Bundler options | build.rolldownOptions | input, external, output, Rolldown plugins |
Use Vite's high-level options first. Drop into build.rolldownOptions only when controlling bundler behavior directly.
rolldownOptions Is the Vite 8 Path
import { resolve } from "node:path"
import { defineConfig } from "vite"
export default defineConfig({
build: {
sourcemap: true,
manifest: true,
rolldownOptions: {
input: {
index: resolve("index.html"),
admin: resolve("admin/index.html"),
},
external: ["some-cdn-lib"],
output: {
entryFileNames: "assets/[name]-[hash].js",
chunkFileNames: "assets/[name]-[hash].js",
assetFileNames: "assets/[name]-[hash][extname]",
},
},
},
})build.rollupOptions still exists as an alias, but it is deprecated in current Vite 8 config docs. New code should use build.rolldownOptions.
Key Build Options
| Option | Default / meaning | Change it when |
|---|---|---|
build.outDir | "dist" | deployment expects another directory |
build.assetsDir | "assets" | static paths are constrained |
build.target | baseline-widely-available | lower browser target required |
build.sourcemap | false | production debugging or error tracking |
build.manifest | false | backend templates need asset mapping |
build.ssrManifest | false | SSR needs preload/style info |
build.minify | Oxc for client, false for SSR | debugging or terser compatibility |
build.cssMinify | Lightning CSS | CSS minification target differs |
build.chunkImportMap | experimental, false | optimizing chunk cache invalidation |
Target
The default production target is baseline-widely-available. Lowering the target performs syntax transforms; it does not automatically polyfill every runtime API.
export default defineConfig({
build: {
target: "es2020",
},
})Minification
Vite 8 client builds default to Oxc minifier; SSR builds default to no minification:
export default defineConfig({
build: {
minify: "oxc",
},
})build.minify: "esbuild" is deprecated and should only be used as a temporary migration choice when you have verified a specific need.
For debugging:
export default defineConfig({
build: {
minify: false,
sourcemap: true,
},
})CSS minification is separate:
export default defineConfig({
build: {
cssMinify: "lightningcss",
},
})Disable JS and CSS minification separately when diagnosing output bugs.
Multi-Page Builds
import { resolve } from "node:path"
import { defineConfig } from "vite"
export default defineConfig({
build: {
rolldownOptions: {
input: {
index: resolve("index.html"),
dashboard: resolve("dashboard.html"),
settings: resolve("settings.html"),
},
},
},
})Output:
dist/
index.html
dashboard.html
settings.html
assets/
index-HASH.js
dashboard-HASH.js
settings-HASH.js
shared-HASH.jsValidate every entry with pnpm preview or a real static server, especially when deploying under a sub-path.
Backend Entry Builds
When HTML is rendered by a backend, build JS/TS entries and enable a manifest:
export default defineConfig({
build: {
manifest: true,
rolldownOptions: {
input: {
app: "src/main.ts",
admin: "src/admin.ts",
},
},
},
})If modulepreload polyfill is needed, import it in the custom entry:
import "vite/modulepreload-polyfill"See 7.8 · Backend Integration.
Chunk Import Map
build.chunkImportMap is experimental and optimizes chunk cache invalidation:
export default defineConfig({
build: {
chunkImportMap: true,
},
})It solves cache cascading caused by hashed chunk URLs. It is not a code splitting strategy.
Migration Checklist
- Write new config under
build.rolldownOptions; keeprollupOptionsonly temporarily. - Review
build.minify: "esbuild"and remove it unless required. - Enable
build.manifestif a backend reads build output. - Open every multi-page entry after build.
- Align
basewith the deployment path. - Clearly mark experimental build options in project docs.
Check Yourself
- Why is
vite buildnot simply raw Rolldown? - How should
build.rollupOptionsbe migrated in Vite 8? - What do
build.minify: falseandbuild.cssMinify: falsehelp debug? - Why do backend integrations usually need
build.manifest?
// Configure a multi-entry build:
// - index.html, dashboard.html, settings.html
// - sourcemap enabled
// - manifest enabled
// - output JS as assets/[name]-[hash].js
// - do not use deprecated rollupOptions