Skip to content

Commit 71dccff

Browse files
committed
fix(webpack): surface compilation errors when stats.toString is empty
(cherry picked from commit 5668d45)
1 parent 0848208 commit 71dccff

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/webpack/src/webpack.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,14 @@ async function compile (compiler: Compiler) {
240240
const stats = await new Promise<Stats>((resolve, reject) => compiler.run((err, stats) => err ? reject(err) : resolve(stats!)))
241241

242242
if (stats.hasErrors()) {
243+
const formatted = stats.toString({ errors: true, warnings: false, colors: false, errorDetails: true })
244+
const compilationErrors = stats.compilation?.errors ?? []
245+
logger.error(formatted || '(no formatted errors emitted; see compilation errors below)')
246+
for (const err of compilationErrors) {
247+
logger.error(err)
248+
}
243249
const error = new Error('Nuxt build error')
244-
error.stack = stats.toString('errors-only')
250+
error.stack = formatted || compilationErrors.map(e => e.stack || e.message || String(e)).join('\n\n') || error.stack
245251
throw error
246252
}
247253
}

0 commit comments

Comments
 (0)