mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxi): support build:error
hook (#1298)
This commit is contained in:
parent
bfa4a02ca3
commit
7f7794787b
@ -68,12 +68,12 @@ export interface NuxtHooks {
|
||||
'nitro:context': (context: any) => HookResult
|
||||
|
||||
// @nuxt/cli
|
||||
'cli:buildError': (error: unknown) => HookResult
|
||||
'generate:cache:ignore': (ignore: string[]) => HookResult
|
||||
'config': (options: NuxtConfig) => HookResult
|
||||
'run:before': (options: { argv: string[], cmd: { name: string, usage: string, description: string, options: Record<string, any> }, rootDir: string }) => HookResult
|
||||
|
||||
// nuxi
|
||||
'build:error': (error: Error) => HookResult
|
||||
'prepare:types': (options: { references: TSReference[], declarations: string[], tsConfig: TSConfig }) => HookResult
|
||||
|
||||
// @nuxt/core
|
||||
|
@ -24,7 +24,7 @@ export default defineNuxtCommand({
|
||||
|
||||
await writeTypes(nuxt)
|
||||
|
||||
nuxt.hook('error', (err) => {
|
||||
nuxt.hook('build:error', (err) => {
|
||||
consola.error('Nuxt Build Error:', err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
@ -48,5 +48,10 @@ function watch (nuxt: Nuxt) {
|
||||
async function bundle (nuxt: Nuxt) {
|
||||
const useVite = nuxt.options.vite !== false
|
||||
const { bundle } = await (useVite ? import('@nuxt/vite-builder') : import('@nuxt/webpack-builder'))
|
||||
return bundle(nuxt)
|
||||
try {
|
||||
return bundle(nuxt)
|
||||
} catch (error) {
|
||||
await nuxt.callHook('build:error', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user