diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts index 3300d6ecba..7ede5161b0 100644 --- a/packages/cli/src/commands/build.ts +++ b/packages/cli/src/commands/build.ts @@ -1,6 +1,7 @@ import { resolve } from 'upath' import { requireModule } from '../utils/cjs' +import { error } from '../utils/log' export async function invoke (args) { process.env.NODE_ENV = process.env.NODE_ENV || 'production' @@ -9,6 +10,12 @@ export async function invoke (args) { const { loadNuxt, buildNuxt } = requireModule('@nuxt/kit', rootDir) const nuxt = await loadNuxt({ rootDir }) + + nuxt.hook('error', (err) => { + error('Nuxt Build Error:', err) + process.exit(1) + }) + await buildNuxt(nuxt) }