feat(nuxi): reload nuxt when restart hook is called (#19084)

This commit is contained in:
Jakub Andrzejewski 2023-03-01 13:15:01 +01:00 committed by GitHub
parent c7eb891e12
commit 5cfd835163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -38,6 +38,7 @@ Hook | Arguments | Description
`kit:compatibility` | `compatibility, issues` | Allows extending compatibility checks.
`ready` | `nuxt` | Called after Nuxt initialization, when the Nuxt instance is ready to work.
`close` | `nuxt` | Called when Nuxt instance is gracefully closing.
`restart` | - | Called to restart the current Nuxt instance. **This hook is currently only available on the [Edge Channel](/docs/guide/going-further/edge-channel/).** <!-- stabilityedge -->
`modules:before` | - | Called during Nuxt initialization, before installing user modules.
`modules:done` | - | Called during Nuxt initialization, after installing user modules.
`app:resolve` | `app` | Called after resolving the `app` instance.

View File

@ -89,6 +89,8 @@ export default defineNuxtCommand({
}
currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false })
currentNuxt.hooks.hookOnce('restart', () => load(true))
if (!isRestart) {
showURL()
}

View File

@ -73,6 +73,11 @@ export interface NuxtHooks {
* @returns Promise
*/
'close': (nuxt: Nuxt) => HookResult
/**
* Called to restart the current Nuxt instance.
* @returns Promise
*/
'restart': () => HookResult
/**
* Called during Nuxt initialization, before installing user modules.