Configure options below — the preview updates in real time.

Shared Options

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.

Clear ScreenWhether to clear the terminal screen when logging certain messages.

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.

Server Options

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.

Strict PortExit if the port is already in use instead of trying the next available port.
HTTPSEnable TLS + HTTP/2 for the dev server. Pass an https.ServerOptions object to configure. Use @vitejs/plugin-basic-ssl for simple setup.

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.

HMREnable or disable Hot Module Replacement. Set to false to disable.
HMR OverlayShow server error overlay in the browser.

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.

Middleware ModeCreate Vite server in middleware mode for use with custom Express or Connect servers.
FS StrictRestrict serving files outside of the workspace root for security.

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.

Build Options

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.

CSS Code SplitEnable CSS code splitting. If disabled, all CSS is extracted into a single file.

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.

ManifestGenerate a manifest.json mapping non-hashed asset names to hashed versions.
SSR ManifestGenerate SSR manifest for determining preload directives.

Produce SSR-oriented build. Set to true or a string path to the SSR entry point.

SSR Emit AssetsForce Vite to emit static assets during SSR builds (normally omitted).
Empty Output DirectoryEmpty the output directory before each build.
Copy Public DirectoryWhether files from publicDir are copied to the output directory.
Report Compressed SizeEnable gzip-compressed size reporting after build. Disabling improves build speed.

Limit in kBs for chunk size warnings.

Write to DiskSet to false to disable writing the bundle to disk (useful for programmatic builds).
Module PreloadConfigure module preload polyfill and preload generation logic.
License FileGenerate a separate license file for bundled third-party code.

Resolve Options

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.

browsermodulejsnext:mainjsnext

File extensions to try for imports that omit extensions.

.mjs.js.mts.ts.jsx.tsx.json
Preserve SymlinksDetermine file identity by the original file path instead of following symlinks.
TSConfig PathsUse paths defined in tsconfig.json compilerOptions.paths for module resolution.

CSS Options

CSS processing and transformation settings.

Dev Source MapsEnable CSS source maps during development.

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.

Preview Options

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.

Preview Strict PortExit if the preview port is already in use.
Preview HTTPSEnable TLS + HTTP/2 for the preview server.

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.

Dependency Optimization

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.

ForceForce dependency pre-bundling, ignoring the existing cache.
Hold Until Crawl EndHold server from serving requests until the initial dependency crawl phase finishes.
No DiscoveryPrevent Vite from discovering and optimizing new dependencies automatically.

Force ESM interop when importing these dependencies.

SSR Options

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.

node

Fields in package.json to try when resolving a package entry point during SSR.

modulejsnext:mainjsnext

JSON Options

Configure how JSON files are imported.

Named ExportsSupport named imports from .json files.

Controls whether imported JSON is transformed to export default JSON.parse() for better performance. 'auto' stringifies when the JSON is large.

Worker Options

Configuration for web worker bundling.

Output format for the web worker bundle.