From 55a3427ef8ff491de913f304cb404551e33265bd Mon Sep 17 00:00:00 2001 From: Julius <45975811+nedjulius@users.noreply.github.com> Date: Thu, 8 Feb 2024 01:22:54 -0500 Subject: [PATCH] fix: pass `customLogger` to `loadConfigFromFile` (fix #15824) (#15831) --- docs/guide/api-javascript.md | 1 + packages/vite/src/node/config.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/guide/api-javascript.md b/docs/guide/api-javascript.md index 33ff9a194343dc..fbfba3b7d9e2c8 100644 --- a/docs/guide/api-javascript.md +++ b/docs/guide/api-javascript.md @@ -397,6 +397,7 @@ async function loadConfigFromFile( configFile?: string, configRoot: string = process.cwd(), logLevel?: LogLevel, + customLogger?: Logger, ): Promise<{ path: string config: UserConfig diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 882129c3893d53..e236c97541a3f5 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -459,6 +459,7 @@ export async function resolveConfig( configFile, config.root, config.logLevel, + config.customLogger, ) if (loadResult) { config = mergeConfig(loadResult.config, config) @@ -963,6 +964,7 @@ export async function loadConfigFromFile( configFile?: string, configRoot: string = process.cwd(), logLevel?: LogLevel, + customLogger?: Logger, ): Promise<{ path: string config: UserConfig @@ -1016,9 +1018,11 @@ export async function loadConfigFromFile( dependencies: bundled.dependencies, } } catch (e) { - createLogger(logLevel).error( + createLogger(logLevel, { customLogger }).error( colors.red(`failed to load config from ${resolvedPath}`), - { error: e }, + { + error: e, + }, ) throw e }