diff --git a/packages/build-info/src/frameworks/angular.test.ts b/packages/build-info/src/frameworks/angular.test.ts index 6229a35e60..966ae11641 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('dist/') + expect(detected?.[0].build.directory).toBe(fs.join('dist', 'demo', 'browser')) expect(detected?.[0].dev?.command).toBe('ng serve') expect(detected?.[0].plugins).toEqual(['@netlify/angular-runtime']) }) @@ -28,5 +40,6 @@ test('should only install plugin on v17+', async ({ fs }) => { 'angular.json': '', }) const detected = await new Project(fs, cwd).detectFrameworks() + expect(detected?.[0].build.directory).toBe('dist/') expect(detected?.[0].plugins).toEqual([]) }) diff --git a/packages/build-info/src/frameworks/angular.ts b/packages/build-info/src/frameworks/angular.ts index 007941a4f5..cd50c4bd6b 100644 --- a/packages/build-info/src/frameworks/angular.ts +++ b/packages/build-info/src/frameworks/angular.ts @@ -32,6 +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') + 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 = this.project.fs.join(outputPath, 'browser') + } + } } return this as DetectedFramework }