Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit fa5e52c

Browse files
abomadidanbucholtz
authored andcommitted
feature(webpack): Propagate errors from webpack stats (#871)
* Propagate errors from webpack stats Prior to this patch, the script would only raise errors raised directly by webpack and skip errors raised from the compilation. This is contrary to what webpack suggests in terms of error handling[1]. This patch makes it so that any compilation errors will cause ionic to also abort the build, while any compilation warnings will log a warning through ionic's Logger. * Update webpack.ts
1 parent 547dc65 commit fa5e52c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/webpack.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,20 @@ export function runWebpackFullBuild(config: WebpackConfig) {
140140
const callback = (err: Error, stats: any) => {
141141
if (err) {
142142
reject(new BuildError(err));
143-
} else {
144-
resolve(stats);
143+
}
144+
else {
145+
const info = stats.toJson();
146+
147+
if (stats.hasErrors()) {
148+
reject(new BuildError(info.errors));
149+
}
150+
else if (stats.hasWarnings()) {
151+
Logger.debug(info.warnings)
152+
resolve(stats);
153+
}
154+
else {
155+
resolve(stats);
156+
}
145157
}
146158
};
147159
const compiler = webpackApi(config);

0 commit comments

Comments
 (0)