Skip to content

Commit dc82929

Browse files
👷 when webpack has errors, print stats and fail the script (#4029)
1 parent b463a51 commit dc82929

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

‎scripts/build/build-package.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,24 @@ async function buildBundle({ filename, verbose }: { filename: string; verbose: b
6363
(error, stats) => {
6464
if (error) {
6565
reject(error)
66-
return
66+
} else if (!stats) {
67+
reject(new Error('Webpack did not return stats'))
68+
} else if (stats.hasErrors()) {
69+
printStats(stats)
70+
reject(new Error('Failed to build bundle due to Webpack errors'))
71+
} else {
72+
if (verbose) {
73+
printStats(stats)
74+
}
75+
resolve()
6776
}
68-
69-
if (verbose) {
70-
console.log(stats!.toString({ colors: true }))
71-
}
72-
resolve()
7377
}
7478
)
7579
})
80+
81+
function printStats(stats: webpack.Stats) {
82+
console.log(stats.toString({ colors: true }))
83+
}
7684
}
7785

7886
async function buildModules({ outDir, module, verbose }: { outDir: string; module: string; verbose: boolean }) {

0 commit comments

Comments
 (0)