Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): fail browser build when index gen…
Browse files Browse the repository at this point in the history
…eration fails

Currently, when there is an error during index generation this is just been logged in the console.

(cherry picked from commit c65b049)
  • Loading branch information
alan-agius4 authored and filipesilva committed Jul 9, 2021
1 parent 30638d4 commit 7cad85d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/angular_devkit/build_angular/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ export function buildWebpackBrowser(
postTransform: transforms.indexHtml,
});

let hasErrors = false;
for (const [locale, outputPath] of outputPaths.entries()) {
try {
const { content, warnings, errors } = await indexHtmlGenerator.process({
Expand All @@ -663,7 +664,10 @@ export function buildWebpackBrowser(
if (warnings.length || errors.length) {
spinner.stop();
warnings.forEach((m) => context.logger.warn(m));
errors.forEach((m) => context.logger.error(m));
errors.forEach((m) => {
context.logger.error(m);
hasErrors = true;
});
spinner.start();
}

Expand All @@ -677,7 +681,13 @@ export function buildWebpackBrowser(
}
}

spinner.succeed('Index html generation complete.');
if (hasErrors) {
spinner.fail('Index html generation failed.');

return { success: false };
} else {
spinner.succeed('Index html generation complete.');
}
}

if (options.serviceWorker) {
Expand Down

0 comments on commit 7cad85d

Please sign in to comment.