loadConfigFromFile() — vite Function Reference
Architecture documentation for the loadConfigFromFile() function in config.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 53f0a505_9626_e709_c92b_e7f00c6e0bd7["loadConfigFromFile()"] 7da774f9_eca5_d54e_6e01_6bee7d460a2b["config.ts"] 53f0a505_9626_e709_c92b_e7f00c6e0bd7 -->|defined in| 7da774f9_eca5_d54e_6e01_6bee7d460a2b 58c4a210_68fe_1b4d_ed49_d59203f97ef1["resolveConfig()"] 58c4a210_68fe_1b4d_ed49_d59203f97ef1 -->|calls| 53f0a505_9626_e709_c92b_e7f00c6e0bd7 dfa2b928_25a4_a78f_1e11_1e7e643cae09["resolve()"] 53f0a505_9626_e709_c92b_e7f00c6e0bd7 -->|calls| dfa2b928_25a4_a78f_1e11_1e7e643cae09 2aff86e8_0c9d_22cb_6536_c1321e1aaa1d["isObject()"] 53f0a505_9626_e709_c92b_e7f00c6e0bd7 -->|calls| 2aff86e8_0c9d_22cb_6536_c1321e1aaa1d a4adb1a7_cf54_091f_eb63_8217e684a8e1["normalizePath()"] 53f0a505_9626_e709_c92b_e7f00c6e0bd7 -->|calls| a4adb1a7_cf54_091f_eb63_8217e684a8e1 04e3b119_ae40_14a9_42ce_3951d83fc60d["createLogger()"] 53f0a505_9626_e709_c92b_e7f00c6e0bd7 -->|calls| 04e3b119_ae40_14a9_42ce_3951d83fc60d 1ce04abd_e38d_39ef_c5e9_a9ef75086f4f["checkBadCharactersInPath()"] 53f0a505_9626_e709_c92b_e7f00c6e0bd7 -->|calls| 1ce04abd_e38d_39ef_c5e9_a9ef75086f4f 8127cae8_510b_1333_1a76_2d21b503c3a6["error()"] 53f0a505_9626_e709_c92b_e7f00c6e0bd7 -->|calls| 8127cae8_510b_1333_1a76_2d21b503c3a6 style 53f0a505_9626_e709_c92b_e7f00c6e0bd7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/config.ts lines 2235–2312
export async function loadConfigFromFile(
configEnv: ConfigEnv,
configFile?: string,
configRoot: string = process.cwd(),
logLevel?: LogLevel,
customLogger?: Logger,
configLoader: 'bundle' | 'runner' | 'native' = 'bundle',
): Promise<{
path: string
config: UserConfig
dependencies: string[]
} | null> {
if (
configLoader !== 'bundle' &&
configLoader !== 'runner' &&
configLoader !== 'native'
) {
throw new Error(
`Unsupported configLoader: ${configLoader}. Accepted values are 'bundle', 'runner', and 'native'.`,
)
}
const start = performance.now()
const getTime = () => `${(performance.now() - start).toFixed(2)}ms`
let resolvedPath: string | undefined
if (configFile) {
// explicit config path is always resolved from cwd
resolvedPath = path.resolve(configFile)
} else {
// implicit config file loaded from inline root (if present)
// otherwise from cwd
for (const filename of DEFAULT_CONFIG_FILES) {
const filePath = path.resolve(configRoot, filename)
if (!fs.existsSync(filePath)) continue
resolvedPath = filePath
break
}
}
if (!resolvedPath) {
debug?.('no config file found.')
return null
}
try {
const resolver =
configLoader === 'bundle'
? bundleAndLoadConfigFile
: configLoader === 'runner'
? runnerImportConfigFile
: nativeImportConfigFile
const { configExport, dependencies } = await resolver(resolvedPath)
debug?.(`config file loaded in ${getTime()}`)
const config = await (typeof configExport === 'function'
? configExport(configEnv)
: configExport)
if (!isObject(config)) {
throw new Error(`config must export or return an object.`)
}
return {
path: normalizePath(resolvedPath),
config,
dependencies,
}
} catch (e) {
const logger = createLogger(logLevel, { customLogger })
checkBadCharactersInPath('The config path', resolvedPath, logger)
logger.error(colors.red(`failed to load config from ${resolvedPath}`), {
error: e,
})
throw e
}
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does loadConfigFromFile() do?
loadConfigFromFile() is a function in the vite codebase, defined in packages/vite/src/node/config.ts.
Where is loadConfigFromFile() defined?
loadConfigFromFile() is defined in packages/vite/src/node/config.ts at line 2235.
What does loadConfigFromFile() call?
loadConfigFromFile() calls 6 function(s): checkBadCharactersInPath, createLogger, error, isObject, normalizePath, resolve.
What calls loadConfigFromFile()?
loadConfigFromFile() is called by 1 function(s): resolveConfig.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free