feat(nuxt): add nitro:build:public-assets hook (#19638)

This commit is contained in:
Daniel Roe 2023-03-14 10:34:55 +00:00 committed by GitHub
parent 88a5f38de0
commit 9d850a2a12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -60,6 +60,7 @@ Hook | Arguments | Description
`nitro:config` | `nitroConfig` | Called before initializing Nitro, allowing customization of Nitro's configuration.
`nitro:init` | `nitro` | Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
`nitro:build:before` | `nitro` | Called before building the Nitro instance.
`nitro:build:public-assets` | `nitro` | Called after copying public assets. Allows modifying public assets before Nitro server is built.
`prerender:routes` | `ctx` | Allows extending the routes to be pre-rendered.
`build:error` | `error` | Called when an error occurs at build time.
`prepare:types` | `options` | Called before Nuxi writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json`

View File

@ -252,6 +252,7 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
} else {
await prepare(nitro)
await copyPublicAssets(nitro)
await nuxt.callHook('nitro:build:public-assets', nitro)
await prerender(nitro)
if (!nuxt.options._generate) {
logger.restoreAll()

View File

@ -217,6 +217,12 @@ export interface NuxtHooks {
* @returns Promise
*/
'nitro:build:before': (nitro: Nitro) => HookResult
/**
* Called after copying public assets. Allows modifying public assets before Nitro server is built.
* @param nitro The created nitro object
* @returns Promise
*/
'nitro:build:public-assets': (nitro: Nitro) => HookResult
/**
* Allows extending the routes to be pre-rendered.
* @param ctx Nuxt context