@@ -12,7 +12,7 @@ const et = require('elementtree');
1212const path = require ( 'path' ) ;
1313const npmCache = require ( './npm-cache' ) ;
1414const { showConfirmation } = require ( './requirements' ) ;
15- const { isDirectory } = require ( './utils' ) ;
15+ const { isDirectory, readAndReplaceFileContent } = require ( './utils' ) ;
1616
1717const loggerLabel = 'wm-cordova-cli' ;
1818
@@ -142,6 +142,15 @@ async function updatePackageJson(dest, cordovaVersion, cordovaIosVersion, cordov
142142 fs . writeFileSync ( projectDir + 'config.xml' , data ) ;
143143}
144144
145+ async function setIsAppConnectedToPreviewToFalse ( projectDir ) {
146+ const writeFn = function ( content ) {
147+ return content . replace ( / i s A p p C o n n e c t e d T o P r e v i e w \( \) / , 'isAppConnectedToPreview() && false' ) ;
148+ } ;
149+ const mobileScriptDir = `${ projectDir } www/wmmobile/scripts` ;
150+ await readAndReplaceFileContent ( `${ mobileScriptDir } /wm-mobileloader.js` , writeFn ) ;
151+ await readAndReplaceFileContent ( `${ mobileScriptDir } /wm-mobileloader.min.js` , writeFn ) ;
152+ }
153+
145154async function getDefaultDestination ( projectDir , platform ) {
146155 let data = fs . readFileSync ( projectDir + 'config.xml' ) . toString ( ) ;
147156 const config = et . parse ( data ) ;
@@ -278,6 +287,9 @@ module.exports = {
278287 label : loggerLabel ,
279288 message : `Building at : ${ config . src } `
280289 } ) ;
290+ if ( args . buildType === 'release' ) {
291+ await setIsAppConnectedToPreviewToFalse ( config . src ) ;
292+ }
281293 await updatePackageJson ( args . dest , args . cordovaVersion , args . cordovaIosVersion , args . cordovaAndroidVersion ) ;
282294 const cordovaToUse = args . cordovaVersion ? config . src + 'node_modules/cordova/bin/cordova' : 'cordova' ;
283295 const cordovaVersion = args . cordovaVersion || ( await exec ( 'cordova' , [ '--version' ] ) ) . join ( '' ) . match ( / [ 0 - 9 ] [ 0 - 9 \. ] + / ) [ 0 ] ;
0 commit comments