@@ -20,34 +20,38 @@ export class CordovaServeBuilder implements Builder<CordovaServeBuilderSchema> {
2020 const devServerBuilderConfig = this . context . architect . getBuilderConfiguration < DevServerBuilderOptions > ( devServerTargetSpec ) ;
2121
2222 let devServerDescription : BuilderDescription ;
23+ let cordovaBuildConfig : BuilderConfiguration < CordovaBuildBuilderSchema > ;
2324
2425 return this . context . architect . getBuilderDescription ( devServerBuilderConfig ) . pipe (
2526 tap ( description => devServerDescription = description ) ,
2627 concatMap ( ( ) => this . context . architect . validateBuilderOptions ( devServerBuilderConfig , devServerDescription ) ) ,
27- concatMap ( ( ) => of ( new CordovaDevServerBuilder ( this . context , builderConfig . options ) ) ) ,
28- // concatMap(() => of(this.context.architect.getBuilder(devServerDescription, this.context))),
28+ concatMap ( ( ) => this . _getCordovaBuildConfig ( builderConfig . options ) ) ,
29+ tap ( config => cordovaBuildConfig = config ) ,
30+ concatMap ( ( ) => of ( new CordovaDevServerBuilder ( this . context , cordovaBuildConfig . options ) ) ) ,
2931 concatMap ( builder => builder . run ( devServerBuilderConfig ) )
3032 ) ;
3133 }
34+
35+ protected _getCordovaBuildConfig ( cordovaServeOptions : CordovaServeBuilderSchema ) : Observable < BuilderConfiguration < CordovaBuildBuilderSchema > > {
36+ const { platform } = cordovaServeOptions ;
37+ const [ project , target , configuration ] = cordovaServeOptions . cordovaBuildTarget . split ( ':' ) ;
38+ const cordovaBuildTargetSpec = { project, target, configuration, overrides : { platform } } ;
39+ const cordovaBuildTargetConfig = this . context . architect . getBuilderConfiguration < CordovaBuildBuilderSchema > ( cordovaBuildTargetSpec ) ;
40+
41+ return this . context . architect . getBuilderDescription ( cordovaBuildTargetConfig ) . pipe (
42+ concatMap ( cordovaBuildDescription => this . context . architect . validateBuilderOptions ( cordovaBuildTargetConfig , cordovaBuildDescription ) )
43+ ) ;
44+ }
3245}
3346
3447class CordovaDevServerBuilder extends DevServerBuilder {
35- constructor ( context : BuilderContext , public cordovaServeOptions : CordovaServeBuilderSchema ) {
48+ constructor ( context : BuilderContext , public cordovaBuildOptions : CordovaBuildBuilderSchema ) {
3649 super ( context ) ;
3750 }
3851
39- // run(builderConfig: BuilderConfiguration</* DevServerBuilderOptions */any>): Observable<BuildEvent> {
40- // return super.run(builderConfig);
41- // }
42-
4352 buildWebpackConfig ( root : Path , projectRoot : Path , host : virtualFs . Host < ζfs . Stats > , browserOptions : BrowserBuilderSchema ) {
44- const { platform } = this . cordovaServeOptions ;
45- const [ project , target , configuration ] = this . cordovaServeOptions . cordovaBuildTarget . split ( ':' ) ;
46- const cordovaBuildTargetSpec = { project, target, configuration, overrides : { platform } } ;
47- const cordovaBuildTargetConfig = this . context . architect . getBuilderConfiguration < CordovaBuildBuilderSchema > ( cordovaBuildTargetSpec ) ;
48-
4953 const builder = new CordovaBuildBuilder ( this . context ) ;
50- builder . prepareBrowserConfig ( cordovaBuildTargetConfig . options , browserOptions ) ;
54+ builder . prepareBrowserConfig ( this . cordovaBuildOptions , browserOptions ) ;
5155
5256 return super . buildWebpackConfig ( root , projectRoot , host , browserOptions ) ;
5357 }
0 commit comments