Skip to content

Commit 9477ff8

Browse files
author
Vladimir Pouzanov
committed
Bubble up errors from webpack run
1 parent afd09d1 commit 9477ff8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/gatsby/src/commands/build-javascript.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@ module.exports = async program => {
1111
`build-javascript`
1212
)
1313

14-
return new Promise(resolve => {
15-
webpack(compilerConfig.resolve()).run(() => resolve())
14+
return new Promise((resolve, reject) => {
15+
webpack(compilerConfig.resolve()).run((err, stats) => {
16+
if (err) {
17+
reject(err)
18+
return
19+
}
20+
21+
const jsonStats = stats.toJson()
22+
if (jsonStats.errors && jsonStats.errors.length > 0) {
23+
reject(jsonStats.errors[0])
24+
return
25+
}
26+
27+
resolve()
28+
})
1629
})
1730
}

0 commit comments

Comments
 (0)