diff --git a/packages/nuxt/src/core/app.ts b/packages/nuxt/src/core/app.ts index dd030ed4a1..565e5e2959 100644 --- a/packages/nuxt/src/core/app.ts +++ b/packages/nuxt/src/core/app.ts @@ -33,8 +33,10 @@ export async function generateApp (nuxt: Nuxt, app: NuxtApp, options: { filter?: // Compile templates into vfs const templateContext = { utils: templateUtils, nuxt, app } - await Promise.all((app.templates as Array>) + const filteredTemplates = (app.templates as Array>) .filter(template => !options.filter || options.filter(template)) + + await Promise.all(filteredTemplates .map(async (template) => { const contents = await compileTemplate(template, templateContext) @@ -55,7 +57,7 @@ export async function generateApp (nuxt: Nuxt, app: NuxtApp, options: { filter?: } })) - await nuxt.callHook('app:templatesGenerated', app) + await nuxt.callHook('app:templatesGenerated', app, filteredTemplates, options) } async function resolveApp (nuxt: Nuxt, app: NuxtApp) { diff --git a/packages/schema/src/types/hooks.ts b/packages/schema/src/types/hooks.ts index ba6f7c8c2a..6bd5fc3a91 100644 --- a/packages/schema/src/types/hooks.ts +++ b/packages/schema/src/types/hooks.ts @@ -123,7 +123,7 @@ export interface NuxtHooks { * @param app The configured `NuxtApp` object * @returns Promise */ - 'app:templatesGenerated': (app: NuxtApp) => HookResult + 'app:templatesGenerated': (app: NuxtApp, templates: ResolvedNuxtTemplate[], options?: GenerateAppOptions) => HookResult /** * Called before Nuxt bundle builder.