mergeConfigRecursively() — vite Function Reference
Architecture documentation for the mergeConfigRecursively() function in utils.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD abeb4de2_5f7e_d2cb_33fc_4ad60bd944ca["mergeConfigRecursively()"] 031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"] abeb4de2_5f7e_d2cb_33fc_4ad60bd944ca -->|defined in| 031bc221_67a8_c579_f2bf_bb30a08beeb2 657661b0_3b17_9113_8464_fda5dfafd706["mergeConfig()"] 657661b0_3b17_9113_8464_fda5dfafd706 -->|calls| abeb4de2_5f7e_d2cb_33fc_4ad60bd944ca f56ee71e_4165_1d46_cf2e_e9dc68848891["setupRollupOptionCompat()"] abeb4de2_5f7e_d2cb_33fc_4ad60bd944ca -->|calls| f56ee71e_4165_1d46_cf2e_e9dc68848891 ffdca39a_602b_3cd5_f0cb_b04f94c0de84["mergeAlias()"] abeb4de2_5f7e_d2cb_33fc_4ad60bd944ca -->|calls| ffdca39a_602b_3cd5_f0cb_b04f94c0de84 f10a0386_5185_97a7_6c91_f1778be9f4fa["backwardCompatibleWorkerPlugins()"] abeb4de2_5f7e_d2cb_33fc_4ad60bd944ca -->|calls| f10a0386_5185_97a7_6c91_f1778be9f4fa 19ce2051_6a74_4b8b_104d_ec006cd7075f["arraify()"] abeb4de2_5f7e_d2cb_33fc_4ad60bd944ca -->|calls| 19ce2051_6a74_4b8b_104d_ec006cd7075f 2aff86e8_0c9d_22cb_6536_c1321e1aaa1d["isObject()"] abeb4de2_5f7e_d2cb_33fc_4ad60bd944ca -->|calls| 2aff86e8_0c9d_22cb_6536_c1321e1aaa1d style abeb4de2_5f7e_d2cb_33fc_4ad60bd944ca fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/utils.ts lines 1312–1386
function mergeConfigRecursively(
defaults: Record<string, any>,
overrides: Record<string, any>,
rootPath: string,
) {
const merged: Record<string, any> = { ...defaults }
if (rollupOptionsRootPaths.has(rootPath)) {
setupRollupOptionCompat(merged, rootPath)
}
for (const key in overrides) {
const value = overrides[key]
if (value == null) {
continue
}
let existing = merged[key]
if (key === 'rollupOptions' && rollupOptionsRootPaths.has(rootPath)) {
// if both rollupOptions and rolldownOptions are present,
// ignore rollupOptions and use rolldownOptions
if (overrides.rolldownOptions) continue
existing = merged.rolldownOptions
}
if (existing == null) {
merged[key] = value
continue
}
// fields that require special handling
if (key === 'alias' && (rootPath === 'resolve' || rootPath === '')) {
merged[key] = mergeAlias(existing, value)
continue
} else if (key === 'assetsInclude' && rootPath === '') {
merged[key] = [].concat(existing, value)
continue
} else if (
(((key === 'noExternal' || key === 'external') &&
(rootPath === 'ssr' || rootPath === 'resolve')) ||
(key === 'allowedHosts' && rootPath === 'server')) &&
(existing === true || value === true)
) {
merged[key] = true
continue
} else if (key === 'plugins' && rootPath === 'worker') {
merged[key] = () => [
...backwardCompatibleWorkerPlugins(existing),
...backwardCompatibleWorkerPlugins(value),
]
continue
} else if (key === 'server' && rootPath === 'server.hmr') {
merged[key] = value
continue
}
if (Array.isArray(existing) || Array.isArray(value)) {
merged[key] = [...arraify(existing), ...arraify(value)]
continue
}
if (isObject(existing) && isObject(value)) {
merged[key] = mergeConfigRecursively(
existing,
value,
// treat environment.* as root
rootPath && !environmentPathRE.test(rootPath)
? `${rootPath}.${key}`
: key,
)
continue
}
merged[key] = value
}
return merged
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does mergeConfigRecursively() do?
mergeConfigRecursively() is a function in the vite codebase, defined in packages/vite/src/node/utils.ts.
Where is mergeConfigRecursively() defined?
mergeConfigRecursively() is defined in packages/vite/src/node/utils.ts at line 1312.
What does mergeConfigRecursively() call?
mergeConfigRecursively() calls 5 function(s): arraify, backwardCompatibleWorkerPlugins, isObject, mergeAlias, setupRollupOptionCompat.
What calls mergeConfigRecursively()?
mergeConfigRecursively() is called by 1 function(s): mergeConfig.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free