Skip to content

Commit a322cfe

Browse files
committed
fix: let's detect the right dist dir instead
1 parent 8297435 commit a322cfe

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

packages/build-info/src/frameworks/angular.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,25 @@ beforeEach((ctx) => {
1111
test('should detect Angular', async ({ fs }) => {
1212
const cwd = mockFileSystem({
1313
'package.json': JSON.stringify({ dependencies: { '@angular/cli': '17.0.0' } }),
14-
'angular.json': '',
14+
'angular.json': JSON.stringify({
15+
projects: {
16+
demo: {
17+
architect: {
18+
build: {
19+
options: {
20+
outputPath: 'dist/demo',
21+
},
22+
},
23+
},
24+
},
25+
},
26+
}),
1527
})
1628
const detected = await new Project(fs, cwd).detectFrameworks()
1729
expect(detected?.[0].id).toBe('angular')
1830
expect(detected?.[0].name).toBe('Angular')
1931
expect(detected?.[0].build.command).toBe('ng build --prod')
20-
expect(detected?.[0].build.directory).toBe('')
32+
expect(detected?.[0].build.directory).toBe('dist/demo/browser')
2133
expect(detected?.[0].dev?.command).toBe('ng serve')
2234
expect(detected?.[0].plugins).toEqual(['@netlify/angular-runtime'])
2335
})

packages/build-info/src/frameworks/angular.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ export class Angular extends BaseFramework implements Framework {
3232
if (this.detected) {
3333
if (this.version && gte(this.version, '17.0.0-rc')) {
3434
this.plugins.push('@netlify/angular-runtime')
35-
this.build.directory = '' // will be overwritten by the plugin
35+
const angularJson = await this.project.fs.gracefullyReadFile('angular.json')
36+
if (angularJson) {
37+
const { projects, defaultProject } = JSON.parse(angularJson)
38+
const project = projects[defaultProject ?? Object.keys(projects)[0]]
39+
const outputPath = project?.architect?.build?.options?.outputPath
40+
if (outputPath) {
41+
this.build.directory = `${outputPath}/browser`
42+
}
43+
}
3644
}
3745
return this as DetectedFramework
3846
}

0 commit comments

Comments
 (0)