Config API
VitePress provides several utilities for working with configuration.resolveConfig()
Resolve the VitePress site configuration.Function Signature
Parameters
string
default:"process.cwd()"
The root directory of your VitePress project containing the
.vitepress folder.'serve' | 'build'
default:"'serve'"
The command being run. Affects how certain config options are resolved.
'serve'- Development server mode'build'- Production build mode
string
default:"'development'"
The mode to run in. Passed to Vite and used for environment variable loading.Common values:
'development', 'production', or custom modes.Return Value
object
The fully resolved site configuration object.
string
Absolute path to the project root
string
Absolute path to the source directory
string
Absolute path to the build output directory
string
Absolute path to the cache directory
string
Absolute path to the temp directory
string
Absolute path to the theme directory
SiteData
Site metadata including title, description, base, etc.
string[]
List of all markdown page paths
MarkdownOptions
Markdown processing options
string | undefined
Path to the config file if found
string[]
List of config file dependencies for watching
Examples
Basic Usage
Build Mode
Custom Root
Inspect Configuration
defineConfig()
Type helper for defining VitePress configuration with TypeScript autocompletion.Function Signature
Type Parameters
type
default:"DefaultTheme.Config"
The type of your theme configuration. Use this when you have a custom theme with its own config type.
Parameters
UserConfig<ThemeConfig>
Your VitePress configuration object.
Examples
Basic Configuration
Custom Theme Config
With All Options
defineAdditionalConfig()
Type helper for defining additional/locale-specific configuration.Function Signature
Examples
mergeConfig()
Merge two VitePress configurations.Function Signature
Parameters
UserConfig
Base configuration
UserConfig
Configuration to merge on top of base
boolean
default:"true"
Whether this is a root-level merge. Affects how Vite config is merged.
Examples
resolveUserConfig()
Resolve raw user configuration from config files.Function Signature
Return Value
Returns a tuple containing:- Resolved user configuration
- Path to the config file (if found)
- Array of config file dependencies
Examples
resolveSiteData()
Resolve site metadata from configuration.Function Signature
Examples
createServer()
Create a Vite development server for VitePress.Function Signature
Parameters
string
default:"process.cwd()"
Project root directory
ServerOptions & { base?: string }
Vite server options plus optional base path override
() => Promise<void>
Callback function to restart the server
SiteConfig
Pre-resolved site config (skips config resolution if provided)
Examples
Related
- Configuration Reference - All config options
- Default Theme Config - Theme configuration
- build() - Build API
- serve() - Preview server API