Skip to content

Commit

Permalink
fix: add vike:outDir debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Dec 10, 2023
1 parent 788e178 commit 92240b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions vike/utils/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Namespace =
| 'vike:virtual-files'
| 'vike:stem'
| 'vike:stream'
| 'vike:outDir'
type Debug = ReturnType<typeof createDebugger>

type Options = {
Expand Down
12 changes: 11 additions & 1 deletion vike/utils/getOutDirs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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` */
Expand All @@ -18,6 +20,7 @@ type OutDirs = {
}

function getOutDirs(config: ResolvedConfig): OutDirs {
debug('getOutDirs()', new Error().stack)
let outDirRoot: string
{
const outDir = getOutDirFromViteResolvedConfig(config)
Expand All @@ -30,21 +33,28 @@ 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)
return outDir
} else {
const { outDirClient, outDirServer } = determineOutDirs(outDir)
if (viteIsSSR(config)) {
debug('outDirServer', 'outDirServer')
return outDirServer
} else {
debug('outDirClient', 'outDirClient')
return outDirClient
}
}
Expand Down

0 comments on commit 92240b6

Please sign in to comment.