This document covers Vite's production build system, which transforms source code into optimized bundles for deployment. In Vite 8, the build system is powered by Rolldown (a Rust-based bundler) and Oxc (a Rust-based transformer and minifier), providing a significant performance leap over previous versions that relied on Rollup and esbuild docs/guide/migration.md16-18
The build system handles multiple environments (client, SSR, custom), processes assets, manages CSS, and generates manifests for production deployment. It supports both standard Application Mode (optimized for browsers) and Library Mode (optimized for package distribution) packages/vite/src/node/build.ts307-334
The production build is initiated via the vite build CLI command or the build() Node API packages/vite/src/node/config.ts143-145 Unlike the dev server, which transforms files on-demand, the build system performs a full graph analysis and bundling process.
Sources: packages/vite/src/node/build.ts590-611 packages/vite/src/node/build.ts613-669 packages/vite/src/node/build.ts800-843
ViteBuilderThe ViteBuilder is the central orchestrator for production builds. It manages the lifecycle across all configured environments packages/vite/src/node/build.ts613-669
BuildEnvironmentEach build target (e.g., client, ssr) is encapsulated in a BuildEnvironment. It holds environment-specific configuration, plugins, and its own PluginContainer packages/vite/src/node/build.ts800-843
Vite 8 leverages Rolldown for bundling and Oxc for syntax lowering and minification.
Sources: packages/vite/src/node/build.ts194-200 packages/vite/src/node/build.ts177-181 docs/guide/features.md44-45
The build system is composed of several specialized pipelines. Detailed documentation for each can be found in the child pages:
Orchestrates the sequence of events from configuration resolution to file writing. It supports per-environment builds and handles the differences between library and app modes. For details, see Build Pipeline and Environments.
Manages static assets (images, fonts, etc.). It handles URL resolution, inlining small assets as Base64 via assetsInlineLimit, and generating hashed filenames for long-term caching.
For details, see Asset Handling and Optimization.
Handles CSS bundling, preprocessors (Sass, Less), PostCSS integration, and CSS Modules. It also manages CSS code splitting, where CSS is bundled alongside corresponding JS chunks. For details, see CSS Processing.
Treats index.html as a first-class entry point. It parses HTML to discover scripts and styles, and injects bundled asset URLs back into the final HTML.
For details, see HTML Transformation.
Supports bundling Web Workers using the new Worker(new URL('./worker.js', import.meta.url)) pattern. Workers are bundled as separate entries with their own dependency graphs.
For details, see Web Workers.
Optimizes the output for production. It uses Rolldown's chunking logic for code splitting and Oxc (default) or Terser for minifying the resulting bundles. For details, see Code Splitting and Minification.
| Feature | Dev Server | Production Build |
|---|---|---|
| Bundling | No (Native ESM) | Yes (Rolldown) |
| Transformation | On-demand (per-request) | Full-graph (pre-calculated) |
| Minification | No | Yes (Oxc/LightningCSS) |
| Caching | Browser Cache / HMR | Content Hashing |
| Optimizer | Rolldown (Pre-bundling) | Rolldown (Bundling) |
Sources: docs/guide/index.md9-14 docs/guide/features.md33-40 packages/vite/src/node/optimizer/index.ts35-43
The build system produces metadata files to assist deployment and SSR:
manifest.json file mapping non-hashed asset names to hashed versions, including dependency information packages/vite/src/node/plugins/manifest.ts1-20ssr-manifest.json file used by SSR frameworks to determine which assets to preload for a given route packages/vite/src/node/ssr/ssrManifestPlugin.ts1-20Sources: packages/vite/src/node/build.ts63-66
Refresh this wiki