@@ -39,8 +39,8 @@ export async function ngsscBuild(options: NgsscBuildSchema, context: BuilderCont
39
39
builderName !== '@angular-devkit/build-angular:application'
40
40
? undefined
41
41
: 'server' in builderOptions && builderOptions . server
42
- ? 'server'
43
- : 'browser-only' ,
42
+ ? 'server'
43
+ : 'browser-only' ,
44
44
) ;
45
45
46
46
return result ;
@@ -54,8 +54,11 @@ export async function detectVariablesAndBuildNgsscJson(
54
54
applicationBuilderVariant : ApplicationBuilderVariant = undefined ,
55
55
) {
56
56
const ngsscContext = await detectVariables ( context , options . searchPattern ) ;
57
- // TODO: Fix possible outputPath options.
58
- let outputPath = join ( context . workspaceRoot , builderOptions . outputPath as string ) ;
57
+ const builderOutputPath =
58
+ typeof builderOptions . outputPath === 'string'
59
+ ? builderOptions . outputPath
60
+ : builderOptions . outputPath . base ;
61
+ let outputPath = join ( context . workspaceRoot , builderOutputPath ) ;
59
62
const ngssc = buildNgssc (
60
63
ngsscContext ,
61
64
options ,
@@ -64,10 +67,11 @@ export async function detectVariablesAndBuildNgsscJson(
64
67
applicationBuilderVariant ,
65
68
) ;
66
69
67
- const browserOutputPath = join ( outputPath , 'browser' ) ;
68
- if ( applicationBuilderVariant === 'browser-only ' && existsSync ( browserOutputPath ) ) {
69
- outputPath = browserOutputPath ;
70
+ const browserOutputPaths = [ join ( outputPath , 'browser' ) ] ;
71
+ if ( typeof builderOptions . outputPath !== 'string ' && builderOptions . outputPath . browser ) {
72
+ browserOutputPaths . unshift ( join ( outputPath , builderOptions . outputPath . browser ) ) ;
70
73
}
74
+ outputPath = browserOutputPaths . find ( existsSync ) ?? outputPath ;
71
75
writeFileSync ( join ( outputPath , 'ngssc.json' ) , JSON . stringify ( ngssc , null , 2 ) , 'utf8' ) ;
72
76
}
73
77
0 commit comments