perf: avoid double resolve user config on startup

pull/317/head
Evan You 4 years ago
parent 55de7ab43c
commit 5733fc625e

@ -47,7 +47,7 @@ export async function resolveConfig(
root: string = process.cwd() root: string = process.cwd()
): Promise<SiteConfig> { ): Promise<SiteConfig> {
const userConfig = await resolveUserConfig(root) const userConfig = await resolveUserConfig(root)
const site = await resolveSiteData(root) const site = await resolveSiteData(root, userConfig)
// resolve theme path // resolve theme path
const userThemeDir = resolve(root, 'theme') const userThemeDir = resolve(root, 'theme')
@ -90,9 +90,11 @@ export async function resolveUserConfig(root: string) {
return userConfig return userConfig
} }
export async function resolveSiteData(root: string): Promise<SiteData> { export async function resolveSiteData(
const userConfig = await resolveUserConfig(root) root: string,
userConfig?: UserConfig
): Promise<SiteData> {
userConfig = userConfig || (await resolveUserConfig(root))
return { return {
lang: userConfig.lang || 'en-US', lang: userConfig.lang || 'en-US',
title: userConfig.title || 'VitePress', title: userConfig.title || 'VitePress',

Loading…
Cancel
Save