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.
  • Loading branch information
alan-agius4 authored and filipesilva committed Jul 9, 2021
1 parent 720feee commit c65b049
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
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 c65b049

Please sign in to comment.