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

-c, --config
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.
vite --config vite.config.prod.js
vite build --config custom-config.js
vite --config config/vite.staging.js
--base
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.
vite --base /my-app/
vite build --base https://cdn.example.com/
vite --base ./  # relative base for file protocol
When using a relative base like ./, make sure all asset paths are relative.
--configLoader
'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)
vite --configLoader runner
vite build --configLoader native

Logging

-l, --logLevel
'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
vite --logLevel warn
vite build --logLevel silent
vite --logLevel error
--clearScreen
boolean
default:true
Allow or disable clearing the terminal screen when logging.
vite --clearScreen false
vite build --clearScreen false

Debugging

-d, --debug
string | boolean
Show debug logs. Can optionally filter by namespace.
vite --debug
vite --debug vite:*
vite --debug vite:transform
vite build -d
You can use glob patterns to filter debug logs:
vite --debug vite:*         # All vite debug logs
vite --debug vite:deps      # Dependency optimization logs
vite --debug vite:transform # Transform logs
vite --debug *              # All debug logs
-f, --filter
string
Filter debug logs by pattern.
vite --debug --filter react
vite --debug vite:* --filter transform

Environment

-m, --mode
string
Set the environment mode. This determines which .env file is loaded.
vite --mode development
vite build --mode staging
vite --mode production
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

-h, --help
boolean
Display available CLI options.
vite --help
vite build --help
vite preview -h
-v, --version
boolean
Display the Vite version number.
vite --version
vite -v

Dev Server Options

Options specific to the vite command (dev server).

Network

--host
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
vite --host                    # Listen on all addresses
vite --host 0.0.0.0           # Listen on all addresses
vite --host 192.168.1.100     # Listen on specific IP
--port
number
default:5173
Specify the port number for the dev server.
vite --port 3000
vite --port 8080
If the port is already in use, Vite will automatically try the next available port unless --strictPort is specified.
--strictPort
boolean
Exit if the specified port is already in use instead of trying the next available port.
vite --port 3000 --strictPort
--cors
boolean
Enable CORS for the dev server. Allows requests from any origin.
vite --cors

Browser

--open
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
vite --open                   # Open to /
vite --open /docs             # Open to /docs
vite --open /about/index.html # Open to specific page

Optimization

--force
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.
vite --force

Experimental

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

Build Options

Options specific to the vite build command.

Output

--outDir
string
default:"dist"
Output directory for the production build (relative to project root).
vite build --outDir build
vite build --outDir public/dist
vite build --outDir ../output
--assetsDir
string
default:"assets"
Directory (relative to outDir) to place assets in.
vite build --assetsDir static
vite build --assetsDir public/assets
--emptyOutDir
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.
vite build --outDir ../dist --emptyOutDir

Assets

--assetsInlineLimit
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.
vite build --assetsInlineLimit 8192  # 8kb threshold
vite build --assetsInlineLimit 0     # Disable inlining

Code Processing

--target
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)
vite build --target esnext
vite build --target chrome90
vite build --target safari13
vite build --target es2015
--minify
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
vite build --minify terser
vite build --minify false
vite build --minify esbuild
--sourcemap
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)
vite build --sourcemap
vite build --sourcemap inline
vite build --sourcemap hidden

SSR

--ssr
string
Build the specified entry point for server-side rendering.
vite build --ssr src/entry-server.js
vite build --ssr server.ts

Manifests

--manifest
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
vite build --manifest
vite build --manifest build-manifest.json
vite build --manifest .vite/manifest.json
The manifest is useful for backend integration to resolve hashed filenames.
--ssrManifest
boolean | string
Emit an SSR manifest for determining style links and asset preload directives.
vite build --ssrManifest
vite build --ssrManifest ssr-manifest.json

Watch Mode

-w, --watch
boolean
Enable watch mode. Rebuilds when source files change.
vite build --watch
vite build -w

Experimental

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

Preview Options

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

Optimize Options

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

Environment Variables

You can pass additional arguments to Node.js using environment variables:
# Increase Node.js memory limit
NODE_OPTIONS=--max-old-space-size=4096 vite build

# Enable Node.js debugging
NODE_OPTIONS=--inspect vite

# Set multiple options
NODE_OPTIONS="--max-old-space-size=8192 --trace-warnings" vite build

Passing Arguments to Scripts

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

Examples

Development with Custom Configuration

vite --config vite.config.dev.js --mode development --port 3000 --open

Production Build with Source Maps

vite build --mode production --sourcemap --minify terser --outDir dist

Preview Build with Custom Port

vite preview --port 8080 --host 0.0.0.0 --open

Debug Mode for Transforms

vite --debug vite:transform --filter .tsx

Force Dependency Re-optimization

vite --force --clearScreen false

SSR Build with Manifests

# Build client
vite build --outDir dist/client --manifest

# Build server
vite build --ssr src/entry-server.js --outDir dist/server --ssrManifest