8000 feat(nuxt): expose filtered templates in `app:templatesGenerated` hoo… · nuxt/nuxt@c5f94be · GitHub
[go: up one dir, main page]

Skip to content

Commit c5f94be

Browse files
authored
feat(nuxt): expose filtered templates in app:templatesGenerated hook (#21935)
1 parent 2f734df commit c5f94be

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/nuxt/src/core/app.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ export async function generateApp (nuxt: Nuxt, app: NuxtApp, options: { filter?:
3333

3434
// Compile templates into vfs
3535
const templateContext = { utils: templateUtils, nuxt, app }
36-
await Promise.all((app.templates as Array<ReturnType<typeof normalizeTemplate>>)
36+
const filteredTemplates = (app.templates as Array<ReturnType<typeof normalizeTemplate>>)
3737
.filter(template => !options.filter || options.filter(template))
38+
39+
await Promise.all(filteredTemplates
3840
.map(async (template) => {
3941
const contents = await compileTemplate(template, templateContext)
4042

@@ -55,7 +57,7 @@ export async function generateApp (nuxt: Nuxt, app: NuxtApp, options: { filter?:
5557
}
5658
}))
5759

58-
await nuxt.callHook('app:templatesGenerated', app)
60+
await nuxt.callHook('app:templatesGenerated', app, filteredTemplates, options)
5961
}
6062

6163
async function resolveApp (nuxt: Nuxt, app: NuxtApp) {

packages/schema/src/types/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export interface NuxtHooks {
123123
* @param app The configured `NuxtApp` object
124124
* @returns Promise
125125
*/
126-
'app:templatesGenerated': (app: NuxtApp) => HookResult
126+
'app:templatesGenerated': (app: NuxtApp, templates: ResolvedNuxtTemplate[], options?: GenerateAppOptions) => HookResult
127127

128128
/**
129129
* Called before Nuxt bundle builder.

0 commit comments

Comments
 (0)
0