Skip to main content
Vite’s CLI provides both global options that work with all commands and command-specific options.

Global Options

These options are available for all Vite commands (vite, vite build, vite preview, vite optimize).

Configuration

string
Use a specific configuration file instead of auto-resolving.Vite will automatically try to resolve a config file named vite.config.js inside the project root. Use this option to specify a different config file.
string
default:"/"
Public base path for the application. Must start and end with a slash.This is useful when deploying to a subdirectory or using a CDN.
When using a relative base like ./, make sure all asset paths are relative.
'bundle' | 'runner' | 'native'
default:"bundle"
Specify how to load the configuration file.
  • bundle - Bundle the config with Rolldown (default, most compatible)
  • runner - Process the config on the fly (experimental)
  • native - Load using the native runtime (experimental)

Logging

'info' | 'warn' | 'error' | 'silent'
default:"info"
Set the verbosity level of console output.
  • info - Show all messages (default)
  • warn - Only warnings and errors
  • error - Only errors
  • silent - No output
boolean
default:true
Allow or disable clearing the terminal screen when logging.

Debugging

string | boolean
Show debug logs. Can optionally filter by namespace.
You can use glob patterns to filter debug logs:
string
Filter debug logs by pattern.

Environment

string
Set the environment mode. This determines which .env file is loaded.
By default:
  • vite uses development mode
  • vite build uses production mode
  • vite preview uses production mode
Mode determines which .env.[mode] file is loaded. See Env Variables for more details.

Help & Version

boolean
Display available CLI options.
boolean
Display the Vite version number.

Dev Server Options

Options specific to the vite command (dev server).

Network

string | boolean
Specify which IP addresses the server should listen on.
  • Not set: Listen on localhost only
  • true or no value: Listen on all addresses including LAN and public
  • Specific IP: Listen on that IP address
  • 0.0.0.0: Listen on all addresses
number
default:5173
Specify the port number for the dev server.
If the port is already in use, Vite will automatically try the next available port unless --strictPort is specified.
boolean
Exit if the specified port is already in use instead of trying the next available port.
boolean
Enable CORS for the dev server. Allows requests from any origin.

Browser

boolean | string
Automatically open the app in the browser on server start.
  • true or no value: Open to the root path
  • String: Open to the specified path

Optimization

boolean
Force Vite to ignore the dependency optimization cache and re-bundle.Use this when you want to force a fresh dependency optimization, for example after installing new packages or changing optimization configuration.

Experimental

boolean
Enable experimental full bundle mode.
This is highly experimental and may not work correctly. Do not use in production.

Build Options

Options specific to the vite build command.

Output

string
default:"dist"
Output directory for the production build (relative to project root).
string
default:"assets"
Directory (relative to outDir) to place assets in.
boolean
Force empty the output directory when it’s outside of the project root.By default, Vite will:
  • Empty outDir if it’s inside the project root
  • Warn and not empty if it’s outside the project root
Use this flag to force emptying even when outside root.

Assets

number
default:4096
Static asset base64 inline threshold in bytes.Assets smaller than this will be inlined as base64 strings. Set to 0 to disable inlining.

Code Processing

string
default:"baseline-widely-available"
Transpile target for the build output.Can be a specific browser version or one of the following:
  • baseline-widely-available - Widely available baseline (default)
  • esnext - Latest ECMAScript features
  • Browser name and version (e.g., chrome90, safari13)
boolean | 'terser' | 'esbuild'
default:"esbuild"
Enable/disable minification, or specify the minifier to use.
  • esbuild - Use esbuild (default, faster)
  • terser - Use Terser (slower, better compression)
  • false - Disable minification
boolean | 'inline' | 'hidden'
default:false
Generate source maps for the build.
  • true - Generate separate .map files
  • inline - Inline source maps in the output files
  • hidden - Generate source maps but don’t add source map comments
  • false - Don’t generate source maps (default)

SSR

string
Build the specified entry point for server-side rendering.

Manifests

boolean | string
Emit a manifest file mapping non-hashed asset filenames to their hashed versions.
  • true: Generate manifest.json in outDir
  • String: Custom filename or path for the manifest
The manifest is useful for backend integration to resolve hashed filenames.
boolean | string
Emit an SSR manifest for determining style links and asset preload directives.

Watch Mode

boolean
Enable watch mode. Rebuilds when source files change.

Experimental

boolean
Build all environments. Same as setting builder: {} in the configuration.
This is experimental and may change in future versions.

Preview Options

Options specific to the vite preview command.
string | boolean
Specify which IP addresses the preview server should listen on.
number
default:4173
Specify the port number for the preview server.
boolean
Exit if the specified port is already in use.
boolean | string
Automatically open the app in the browser.
string
default:"dist"
Specify the output directory to serve.

Optimize Options

Options specific to the vite optimize command (deprecated).
boolean
Force the optimizer to ignore the cache and re-bundle dependencies.

Environment Variables

You can pass additional arguments to Node.js using environment variables:

Passing Arguments to Scripts

You can pass extra arguments to your build scripts using --:
These arguments are available in the config via process.argv.

Examples

Development with Custom Configuration

Production Build with Source Maps

Preview Build with Custom Port

Debug Mode for Transforms

Force Dependency Re-optimization

SSR Build with Manifests