diff --git a/packages/angular/cli/models/architect-command.ts b/packages/angular/cli/models/architect-command.ts index 899bd806be..9af118b80d 100644 --- a/packages/angular/cli/models/architect-command.ts +++ b/packages/angular/cli/models/architect-command.ts @@ -270,10 +270,14 @@ export abstract class ArchitectCommand< }, ); - const result = await run.output.toPromise(); + const { error, success } = await run.output.toPromise(); await run.stop(); - return result.success ? 0 : 1; + if (error) { + this.logger.error(error); + } + + return success ? 0 : 1; } } diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/service-worker/index.ts b/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/service-worker/index.ts index fb1baa6ebc..bb712e5b78 100644 --- a/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/service-worker/index.ts +++ b/packages/angular_devkit/build_angular/src/angular-cli-files/utilities/service-worker/index.ts @@ -102,7 +102,7 @@ export async function augmentAppWithServiceWorker( if (!configExists) { throw new Error(tags.oneLine` Error: Expected to find an ngsw-config.json configuration - file in the ${appRoot} folder. Either provide one or disable Service Worker + file in the ${getSystemPath(appRoot)} folder. Either provide one or disable Service Worker in your angular.json configuration file. `); } diff --git a/packages/angular_devkit/build_angular/src/browser/index.ts b/packages/angular_devkit/build_angular/src/browser/index.ts index 7d28a41987..ad875e077e 100644 --- a/packages/angular_devkit/build_angular/src/browser/index.ts +++ b/packages/angular_devkit/build_angular/src/browser/index.ts @@ -261,7 +261,7 @@ export function buildWebpackBrowser( }) .pipe( map(() => ({ success: true })), - catchError(() => of({ success: false })), + catchError(error => of({ success: false, error: mapErrorToMessage(error) })), ); } else { return of({ success }); @@ -276,7 +276,10 @@ export function buildWebpackBrowser( resolve(root, normalize(options.outputPath)), options.baseHref || '/', options.ngswConfigPath, - ).then(() => ({ success: true }), () => ({ success: false }))); + ).then( + () => ({ success: true }), + error => ({ success: false, error: mapErrorToMessage(error) }), + )); } else { return of(buildEvent); } @@ -291,4 +294,16 @@ export function buildWebpackBrowser( ); } +function mapErrorToMessage(error: unknown): string | undefined { + if (error instanceof Error) { + return error.message; + } + + if (typeof error === 'string') { + return error; + } + + return undefined; +} + export default createBuilder(buildWebpackBrowser);