Skip to content

Commit

Permalink
fix: handle webpack errors as described in https://webpack.js.org/api…
Browse files Browse the repository at this point in the history
  • Loading branch information
mediremi authored and KaiVandivier committed Aug 23, 2022
1 parent 3e4275c commit c557534
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cli/src/lib/plugin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = async ({ paths }) => {
const webpackConfig = webpackConfigFactory({ env: 'production', paths })
const compiler = webpack(webpackConfig)
return new Promise((resolve, reject) => {
compiler.run(err => {
compiler.run((err, stats) => {
if (err) {
if (!err.message) {
reject(err)
Expand All @@ -32,6 +32,23 @@ module.exports = async ({ paths }) => {
return
}

const info = stats.toJson()

if (stats.hasErrors()) {
reject(
new Error(
info.errors.map(error => error.message).join('\n')
)
)
return
}

if (stats.hasWarnings()) {
console.warn(info.warnings)
reject(new Error(info.warnings))
return
}

resolve()
})
})
Expand Down

0 comments on commit c557534

Please sign in to comment.