Configure options below — the preview updates in real time.
Root-level options that affect both development and production builds.
Project root directory where index.html is located. Can be an absolute path or relative to the current working directory.
Base public path when served in development or production. Used for deploying under nested paths.
Overrides the default mode, determining which .env files are loaded.
Define global constant replacements during build and dev. Key-value pairs of string to any valid JSON value.
Directory to serve as plain static assets. Files are copied as-is to the build output directory.
Directory to save cache files (e.g., pre-bundled deps).
Adjust console output verbosity.
The directory from which .env files are loaded.
Environment variables starting with this prefix will be exposed to client source code via import.meta.env.
Sets whether the app is a Single Page Application, Multi Page App, or Custom. Modifies middleware behavior.
Configuration for the Vite development server.
Specify which IP addresses the server should listen on. Set to 0.0.0.0 or true to listen on all addresses.
Hostnames that Vite is allowed to respond to. Set specific host strings to mitigate DNS rebinding attacks.
Specify the dev server port.
Automatically open the app in the browser on server start. Set to true or a URL pathname string.
Configure custom proxy rules for the dev server. Map paths to proxy targets.
Configure CORS for the dev server. By default only localhost origins are allowed.
Specify custom response headers for the dev server.
Override the port used on the client-side for the HMR websocket.
Override the host used for the HMR websocket connection.
Override the port used for the HMR websocket connection.
Override the path used for the HMR websocket connection.
Timeout in milliseconds for the HMR websocket connection.
Pre-transform specific client files during server startup to reduce initial load latency.
Pre-transform specific SSR files during server startup to reduce initial load latency.
File system watcher patterns to ignore. Passed to Chokidar.
Additional directories allowed to be served by the dev server.
Patterns for files blocked from being served by the dev server.
Defines the origin of generated asset URLs during development.
Options for production builds.
Browser compatibility target for the final bundle. Can be 'baseline-widely-available', 'esnext', or esbuild targets like 'es2015', 'chrome58'.
Specify the output directory relative to project root.
Directory to nest generated assets under inside the output directory.
Imported assets smaller than this threshold (in bytes) will be inlined as base64 URLs.
Set a different browser target for CSS minification than the JS target.
Override CSS minification strategy independent of JS minification.
Generate production source maps.
Set to false to disable minification, or specify the minifier to use.
Produce SSR-oriented build. Set to true or a string path to the SSR entry point.
Limit in kBs for chunk size warnings.
Module resolution configuration.
Define path aliases for importing modules. Map shorthand paths to their full resolutions.
Force Vite to always resolve listed dependencies to the same copy. Useful for monorepos.
Additional allowed conditions when resolving conditional exports in package.json.
Fields in package.json to try when resolving a package entry point.
File extensions to try for imports that omit extensions.
CSS processing and transformation settings.
The engine used for CSS processing.
Custom directory to search for PostCSS config from, or leave empty for auto-detection.
Maximum number of concurrent workers for CSS preprocessors. Set to true for auto-detection based on CPU count, or specify a number.
Configuration for the vite preview local production-preview server.
IP addresses the preview server should listen on.
Hostnames that the preview server is allowed to respond to. Defaults to server.allowedHosts.
Preview server port.
Automatically open the app in the browser on preview server start.
Configure custom proxy rules for the preview server. Defaults to server.proxy.
Configure CORS for the preview server. Defaults to server.cors.
Specify custom response headers for the preview server.
Options for Vite's dependency pre-bundling and optimization.
Custom entry points for dependency scanning. Overrides default HTML-based inference.
Force linked or hidden packages to be pre-bundled.
Dependencies to exclude from pre-bundling.
Force ESM interop when importing these dependencies.
Server-side rendering configuration.
Force specific dependencies to be externalized during SSR build.
Prevent listed dependencies from being externalized (they will be bundled instead).
Target environment for the SSR server.
Conditions used during SSR module resolving.
Conditions used when importing SSR external dependencies.
Fields in package.json to try when resolving a package entry point during SSR.
Configure how JSON files are imported.
Controls whether imported JSON is transformed to export default JSON.parse() for better performance. 'auto' stringifies when the JSON is large.
Configuration for web worker bundling.
Output format for the web worker bundle.
1import { defineConfig } from "vite";23export default defineConfig({});