From 0bbbddecba324fd237830f350f932a952808ead5 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 15 Jul 2021 13:24:26 +0200 Subject: [PATCH] fix(cli): handle build error and exit with code(1) --- packages/cli/src/commands/build.ts | 7 +++++++ 1 file changed, 7 insertions(+) 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) }