@@ -23,12 +23,25 @@ export class CordovaBuildBuilder implements Builder<CordovaBuildBuilderSchema> {
2323 tap ( description => browserDescription = description ) ,
2424 concatMap ( ( ) => this . context . architect . validateBuilderOptions ( browserConfig , browserDescription ) ) ,
2525 tap ( config => browserConfig = config ) ,
26+ tap ( ( ) => this . validateBuilderConfig ( builderConfig . options ) ) ,
2627 tap ( ( ) => this . prepareBrowserConfig ( builderConfig . options , browserConfig . options ) ) ,
2728 concatMap ( ( ) => of ( this . context . architect . getBuilder ( browserDescription , this . context ) ) ) ,
2829 concatMap ( builder => builder . run ( browserConfig ) )
2930 ) ;
3031 }
3132
33+ // Mutates builderOptions
34+ validateBuilderConfig ( builderOptions : CordovaBuildBuilderSchema ) {
35+ // if we're mocking cordova.js, don't build cordova bundle
36+ if ( builderOptions . cordovaMock ) {
37+ builderOptions . cordovaAssets = false ;
38+ }
39+
40+ if ( builderOptions . cordovaAssets && ! builderOptions . platform ) {
41+ throw new Error ( 'The `--platform` option is required with `--cordova-assets`' ) ;
42+ }
43+ }
44+
3245 // Mutates browserOptions
3346 prepareBrowserConfig ( options : CordovaBuildBuilderSchema , browserOptions : BrowserBuilderSchema ) {
3447 const cordovaBasePath = normalize ( options . cordovaBasePath ? options . cordovaBasePath : '.' ) ;
@@ -41,7 +54,13 @@ export class CordovaBuildBuilder implements Builder<CordovaBuildBuilderSchema> {
4154 // by default. Let's keep it around.
4255 browserOptions . deleteOutputPath = false ;
4356
44- if ( options . cordovaAssets ) {
57+ if ( options . cordovaMock ) {
58+ browserOptions . scripts . push ( {
59+ input : getSystemPath ( join ( normalize ( __dirname ) , normalize ( 'cordova.js' ) ) ) ,
60+ bundleName : 'cordova' ,
61+ lazy : false ,
62+ } ) ;
63+ } else if ( options . cordovaAssets ) {
4564 const platformWWWPath = join ( cordovaBasePath , normalize ( `platforms/${ options . platform } /platform_www` ) ) ;
4665
4766 // Add Cordova www assets that were generated whenever platform(s) and
0 commit comments