From ec6dff42c941c9456790946a92185c6a2089fe09 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 11 Oct 2023 11:27:01 +0200 Subject: [PATCH] fix: update DistributionDir for Angular This commit fixes an issue that for the Angular preset, the DistributionDir was not detected correctly as the `defaultProject` has been removed from the angular.json some major versions ago. This change also adds support for an upcoming change in version 17 were there is a new "builder". --- .../lib/framework-config-mapping.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/amplify-frontend-javascript/lib/framework-config-mapping.js b/packages/amplify-frontend-javascript/lib/framework-config-mapping.js index 4328df978c9..82b8aea1b74 100644 --- a/packages/amplify-frontend-javascript/lib/framework-config-mapping.js +++ b/packages/amplify-frontend-javascript/lib/framework-config-mapping.js @@ -68,11 +68,20 @@ function getAngularConfig(context, projectPath) { context.usageData.emitError(new AngularConfigNotFoundError(errorMessage)); exitOnNextTick(1); } - const dist = _.get( - angularProjectConfig, - ['projects', angularProjectConfig.defaultProject, 'architect', 'build', 'options', 'outputPath'], - 'dist', - ); + + let dist = 'dist'; + try { + const firstProject = Object.values(angularProjectConfig.projects)[0]; + const {builder, options} = firstProject.architect.build; + dist = options.outputPath; + if (builder === '@angular-devkit/build-angular:application') { + // The application builder will output browser files in /browser and server files in /server. + dist + '/browser'; + } + } catch { + context.print.info(`Failed to determine DistributionDir.`); + } + return { ...angularConfig, DistributionDir: dist,