diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 16d5e159a22756..ace3aa5fbbf80a 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -440,6 +440,12 @@ export interface UserConfig extends DefaultEnvironmentOptions { * @default 'spa' */ appType?: AppType + /** + * Specifies the number of times to recurse while formatting object. + * + * https://nodejs.org/api/util.html#utilinspectobject-options + */ + debugDepth?: string | undefined } export interface HTMLOptions { @@ -846,6 +852,10 @@ export async function resolveConfig( configFile = loadResult.path configFileDependencies = loadResult.dependencies } + + if (config.debugDepth && process.env.DEBUG) { + process.env.DEBUG_DEPTH = config.debugDepth + } } // user config may provide an alternative mode. But --mode has a higher priority diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index efe90935dbba68..a0cd140b18fc52 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -176,6 +176,11 @@ export function createDebugger( if (enabled) { return (...args: [string, ...any[]]) => { if (!filter || args.some((a) => a?.includes?.(filter))) { + if (process.env.DEBUG_DEPTH) { + const depth = parseInt(process.env.DEBUG_DEPTH) + // @ts-expect-error - The log function is bound to inspectOpts, but the type is not reflected + log.inspectOpts.depth = depth + } log(...args) } }