Last active
September 4, 2015 01:13
-
-
Save revolunet/328193b350a056d730a5 to your computer and use it in GitHub Desktop.
Cordova before_prepare hook to point the webview to your WEBVIEW_SRC env variable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* | |
cordova webview src changer : force the webview startPage with the env var `WEBVIEW_SRC`. | |
put this script in hooks/before_prepare/webview-src.js and chmod +x it | |
ex: `WEBVIEW_SRC=http://192.168.2.30:9999 cordova prepare` | |
On port 9999 serve the platforms/ios/www folder (which includes cordova.js) | |
This way you dont have to recompile your app to test your web-app changes in the final cordova environnement. | |
You have to run cordova prepare to update the platforms/ios/www folder though | |
*/ | |
var lib = require('cordova').cordova_lib; | |
var config = new lib.configparser(__dirname + '/../../config.xml'); | |
function setWebviewSrc(src) { | |
config.doc.find('content').set('src', src); | |
} | |
setWebviewSrc(process.env.WEBVIEW_SRC); | |
if (process.env.WEBVIEW_SRC) { | |
console.log('set webview startPage to ' + process.env.WEBVIEW_SRC); | |
setWebviewSrc(process.env.WEBVIEW_SRC); | |
} else { | |
setWebviewSrc('index.html'); | |
} | |
config.write(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wordpress-clients/hybrid@36bd651 Beaucoup plus sympa! Thanks