Skip to content

Commit c8bef32

Browse files
committed
fix: respect user configured srcDir
1 parent 38513dc commit c8bef32

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/node/config.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,12 @@ function dirname(path: string) {
187187
async function gatherAdditionalConfig(
188188
root: string,
189189
command: 'serve' | 'build',
190-
mode: string
190+
mode: string,
191+
srcDir: string = '.'
191192
): Promise<[AdditionalConfigDict, string[][]]> {
192193
const pattern = `**/config.{${supportedConfigExtensions.join(',')}}`
193194
const candidates = await glob(pattern, {
194-
cwd: root,
195+
cwd: path.resolve(root, srcDir),
195196
dot: false, // conveniently ignores .vitepress/*
196197
ignore: ['**/node_modules/**', '**/.git/**']
197198
})
@@ -201,7 +202,7 @@ async function gatherAdditionalConfig(
201202
const id = '/' + dirname(slash(file))
202203
const configExports = await loadConfigFromFile(
203204
{ command, mode },
204-
normalizePath(path.resolve(root, file)),
205+
normalizePath(path.resolve(root, srcDir, file)),
205206
root
206207
).catch(console.error) // Skip additionalConfig file if it fails to load
207208
if (!configExports) {
@@ -214,7 +215,7 @@ async function gatherAdditionalConfig(
214215
)
215216
)
216217
if (mode === 'development')
217-
(configExports.config as any)['[VP_SOURCE]'] = file
218+
(configExports.config as any)['[VP_SOURCE]'] = '/' + slash(file)
218219
return [id, configExports.config as AdditionalConfig]
219220
})
220221
)
@@ -254,7 +255,8 @@ export async function resolveUserConfig(
254255
const [additionalConfig, additionalDeps] = await gatherAdditionalConfig(
255256
root,
256257
command,
257-
mode
258+
mode,
259+
userConfig.srcDir
258260
)
259261
userConfig.additionalConfig = additionalConfig
260262
configDeps = configDeps.concat(...additionalDeps)

0 commit comments

Comments
 (0)