diff --git a/packages/kit/src/loader/config.ts b/packages/kit/src/loader/config.ts index 3c5894ea68..b2c4d1b883 100644 --- a/packages/kit/src/loader/config.ts +++ b/packages/kit/src/loader/config.ts @@ -42,10 +42,15 @@ export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise[] = [] + const processedLayers = new Set() for (const layer of layers) { // Resolve `rootDir` & `srcDir` of layers layer.config = layer.config || {} - layer.config.rootDir = layer.config.rootDir ?? layer.cwd + layer.config.rootDir = layer.config.rootDir ?? layer.cwd! + + // Only process/resolve layers once + if (processedLayers.has(layer.config.rootDir)) { continue } + processedLayers.add(layer.config.rootDir) // Normalise layer directories layer.config = await applyDefaults(layerSchema, layer.config as NuxtConfig & Record) as unknown as NuxtConfig