feat(nuxt): support for extending error.vue in layers (#9521)

This commit is contained in:
Alexander Lichter 2022-12-06 10:44:03 +01:00 committed by GitHub
parent 228bc9ce21
commit 5f935aad48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
import { promises as fsp } from 'node:fs'
import { dirname, resolve } from 'pathe'
import { dirname, resolve, join } from 'pathe'
import defu from 'defu'
import type { Nuxt, NuxtApp, NuxtPlugin, NuxtTemplate, ResolvedNuxtTemplate } from '@nuxt/schema'
import { findPath, resolveFiles, normalizePlugin, normalizeTemplate, compileTemplate, templateUtils, tryResolveModule, resolvePath, resolveAlias } from '@nuxt/kit'
@ -74,7 +74,9 @@ export async function resolveApp (nuxt: Nuxt, app: NuxtApp) {
// Resolve error component
if (!app.errorComponent) {
app.errorComponent = (await findPath(['~/error'])) || resolve(nuxt.options.appDir, 'components/nuxt-error-page.vue')
app.errorComponent = (await findPath(
nuxt.options._layers.map(layer => join(layer.config.srcDir, 'error'))
)) ?? resolve(nuxt.options.appDir, 'components/nuxt-error-page.vue')
}
// Resolve layouts/ from all config layers