From 1444af6533d19ea8602f2b29a207ebc4d6d50530 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Wed, 2 Oct 2024 01:30:17 +0800 Subject: [PATCH] perf(theme): improve `findConfigPath` (#246) --- theme/src/node/loadConfig/findConfigPath.ts | 12 +++++++----- theme/src/node/plugins/getPlugins.ts | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/theme/src/node/loadConfig/findConfigPath.ts b/theme/src/node/loadConfig/findConfigPath.ts index 4afdcb6e..deb88c2a 100644 --- a/theme/src/node/loadConfig/findConfigPath.ts +++ b/theme/src/node/loadConfig/findConfigPath.ts @@ -20,11 +20,13 @@ export async function findConfigPath(app: App, configPath?: string): Promise { - paths.push(resolve(cwd, `./${CONFIG_FILE_NAME}.${ext}`)) - paths.push(resolve(cwd, `${source}/${CONFIG_FILE_NAME}.${ext}`)) - paths.push(resolve(cwd, `./.vuepress/${CONFIG_FILE_NAME}.${ext}`)) - }) + extensions.forEach(ext => + paths.push( + resolve(cwd, `${source}/${CONFIG_FILE_NAME}.${ext}`), + resolve(cwd, `./${CONFIG_FILE_NAME}.${ext}`), + resolve(cwd, `./.vuepress/${CONFIG_FILE_NAME}.${ext}`), + ), + ) let current: string | undefined for (const path of paths) { if (existsSync(path) && (await fsp.stat(path)).isFile()) { diff --git a/theme/src/node/plugins/getPlugins.ts b/theme/src/node/plugins/getPlugins.ts index 978de691..0c224ddd 100644 --- a/theme/src/node/plugins/getPlugins.ts +++ b/theme/src/node/plugins/getPlugins.ts @@ -38,7 +38,7 @@ export function getPlugins({ hostname, cache, }: SetupPluginOptions): PluginConfig { - const isProd = !app.env.isDev + const isProd = app.env.isBuild const plugins: PluginConfig = [ markdownTitlePlugin(),