From 92240b65573b0d22555245e5b3d57859bb46d489 Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Sun, 10 Dec 2023 14:03:28 +0100 Subject: [PATCH] fix: add vike:outDir debug logs --- vike/utils/debug.ts | 1 + vike/utils/getOutDirs.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/vike/utils/debug.ts b/vike/utils/debug.ts index 506ab7f550d..19fdd145354 100644 --- a/vike/utils/debug.ts +++ b/vike/utils/debug.ts @@ -24,6 +24,7 @@ type Namespace = | 'vike:virtual-files' | 'vike:stem' | 'vike:stream' + | 'vike:outDir' type Debug = ReturnType type Options = { diff --git a/vike/utils/getOutDirs.ts b/vike/utils/getOutDirs.ts index e2913cec384..e3d5ef97257 100644 --- a/vike/utils/getOutDirs.ts +++ b/vike/utils/getOutDirs.ts @@ -7,6 +7,8 @@ import { assert, assertUsage } from './assert.js' import { pathJoin } from './path-shim.js' import { assertPosixPath, toPosixPath } from './filesystemPathHandling.js' import pc from '@brillout/picocolors' +import { createDebugger } from './debug.js' +const debug = createDebugger('vike:outDir') type OutDirs = { /** Absolute path to `outDir` */ @@ -18,6 +20,7 @@ type OutDirs = { } function getOutDirs(config: ResolvedConfig): OutDirs { + debug('getOutDirs()', new Error().stack) let outDirRoot: string { const outDir = getOutDirFromViteResolvedConfig(config) @@ -30,12 +33,17 @@ function getOutDirs(config: ResolvedConfig): OutDirs { outDirRoot = outDir.slice(0, -1 * '/client'.length) } } - return getOutDirsAll(outDirRoot, config.root) + const outDirs = getOutDirsAll(outDirRoot, config.root) + debug('outDirRoot', outDirRoot) + debug('outDirs', outDirs) + return outDirs } /** Appends `client/` or `server/` to `config.build.outDir` */ function resolveOutDir(config: UserConfig): string { + debug('resolveOutDir()', new Error().stack) const outDir = getOutDirFromViteUserConfig(config) || 'dist' + debug('outDir', 'outDir') // outDir may already be resolved when using Telefunc + vike (because both Telefunc and vike use this logic) if (!isOutDirRoot(outDir)) { assertOutDirResolved(outDir, config) @@ -43,8 +51,10 @@ function resolveOutDir(config: UserConfig): string { } else { const { outDirClient, outDirServer } = determineOutDirs(outDir) if (viteIsSSR(config)) { + debug('outDirServer', 'outDirServer') return outDirServer } else { + debug('outDirClient', 'outDirClient') return outDirClient } }