@@ -187,11 +187,12 @@ function dirname(path: string) {
187
187
async function gatherAdditionalConfig (
188
188
root : string ,
189
189
command : 'serve' | 'build' ,
190
- mode : string
190
+ mode : string ,
191
+ srcDir : string = '.'
191
192
) : Promise < [ AdditionalConfigDict , string [ ] [ ] ] > {
192
193
const pattern = `**/config.{${ supportedConfigExtensions . join ( ',' ) } }`
193
194
const candidates = await glob ( pattern , {
194
- cwd : root ,
195
+ cwd : path . resolve ( root , srcDir ) ,
195
196
dot : false , // conveniently ignores .vitepress/*
196
197
ignore : [ '**/node_modules/**' , '**/.git/**' ]
197
198
} )
@@ -201,7 +202,7 @@ async function gatherAdditionalConfig(
201
202
const id = '/' + dirname ( slash ( file ) )
202
203
const configExports = await loadConfigFromFile (
203
204
{ command, mode } ,
204
- normalizePath ( path . resolve ( root , file ) ) ,
205
+ normalizePath ( path . resolve ( root , srcDir , file ) ) ,
205
206
root
206
207
) . catch ( console . error ) // Skip additionalConfig file if it fails to load
207
208
if ( ! configExports ) {
@@ -214,7 +215,7 @@ async function gatherAdditionalConfig(
214
215
)
215
216
)
216
217
if ( mode === 'development' )
217
- ( configExports . config as any ) [ '[VP_SOURCE]' ] = file
218
+ ( configExports . config as any ) [ '[VP_SOURCE]' ] = '/' + slash ( file )
218
219
return [ id , configExports . config as AdditionalConfig ]
219
220
} )
220
221
)
@@ -254,7 +255,8 @@ export async function resolveUserConfig(
254
255
const [ additionalConfig , additionalDeps ] = await gatherAdditionalConfig (
255
256
root ,
256
257
command ,
257
- mode
258
+ mode ,
259
+ userConfig . srcDir
258
260
)
259
261
userConfig . additionalConfig = additionalConfig
260
262
configDeps = configDeps . concat ( ...additionalDeps )
0 commit comments