From a322cfe7eb407f73ce23f85203d18f27b8fa497a Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 8 Nov 2023 18:27:49 +0100 Subject: [PATCH] fix: let's detect the right dist dir instead --- .../build-info/src/frameworks/angular.test.ts | 16 ++++++++++++++-- packages/build-info/src/frameworks/angular.ts | 10 +++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/build-info/src/frameworks/angular.test.ts b/packages/build-info/src/frameworks/angular.test.ts index 9878ecab5f..de6fdc4d00 100644 --- a/packages/build-info/src/frameworks/angular.test.ts +++ b/packages/build-info/src/frameworks/angular.test.ts @@ -11,13 +11,25 @@ beforeEach((ctx) => { test('should detect Angular', async ({ fs }) => { const cwd = mockFileSystem({ 'package.json': JSON.stringify({ dependencies: { '@angular/cli': '17.0.0' } }), - 'angular.json': '', + 'angular.json': JSON.stringify({ + projects: { + demo: { + architect: { + build: { + options: { + outputPath: 'dist/demo', + }, + }, + }, + }, + }, + }), }) const detected = await new Project(fs, cwd).detectFrameworks() expect(detected?.[0].id).toBe('angular') expect(detected?.[0].name).toBe('Angular') expect(detected?.[0].build.command).toBe('ng build --prod') - expect(detected?.[0].build.directory).toBe('') + expect(detected?.[0].build.directory).toBe('dist/demo/browser') expect(detected?.[0].dev?.command).toBe('ng serve') expect(detected?.[0].plugins).toEqual(['@netlify/angular-runtime']) }) diff --git a/packages/build-info/src/frameworks/angular.ts b/packages/build-info/src/frameworks/angular.ts index 1ff332f251..ce0835cdc9 100644 --- a/packages/build-info/src/frameworks/angular.ts +++ b/packages/build-info/src/frameworks/angular.ts @@ -32,7 +32,15 @@ export class Angular extends BaseFramework implements Framework { if (this.detected) { if (this.version && gte(this.version, '17.0.0-rc')) { this.plugins.push('@netlify/angular-runtime') - this.build.directory = '' // will be overwritten by the plugin + const angularJson = await this.project.fs.gracefullyReadFile('angular.json') + if (angularJson) { + const { projects, defaultProject } = JSON.parse(angularJson) + const project = projects[defaultProject ?? Object.keys(projects)[0]] + const outputPath = project?.architect?.build?.options?.outputPath + if (outputPath) { + this.build.directory = `${outputPath}/browser` + } + } } return this as DetectedFramework }