2016-07-08 9 views
-1

このチュートリアルでApache Cordovaを使用してホストされたWebアプリケーションを開発するためにVisual Studio 2015を使用していますhttp://taco.visualstudio.com/en-us/docs/create-a-hosted-app Cordova WebViewで開いている特定のアプリケーションURLについては、 places(config.xml、index.html、index.js)。このURLは開発環境と運用環境で異なります。そして、プロダクション用のアプリケーションをビルドする前に、いくつかの場所(config.xml、index.html、index.js)でurlを置き換える必要があります。このタスクを自動化することは可能でしょうか(おそらく、gulpとtaco-team-buildモジュールを通して)?ビルド前にホストアプリケーションのURLを変更するVisual StudioのCordovaアプリケーション2015

答えて

0

最終的に私の決定は非常に簡単です。
は、私は、config.xml

<allow-navigation href="http://dev/*" /> 
<allow-navigation href="http://prod/*" /> 

index.htmlを

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: http://dev/ http://prod/ https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> 

そしてindex.jsで I​​3210へと

index.htmlに開発と生産のURLの両方を追加します必要なURLを返す関数を作成します。

function getConnectionInfo(production: boolean): ConnectionInfo 
{ 
    if (production) 
    { 
     return { 
      TargetUrl: 'http://prod/', 
      UsePassword: false, 
      User: '', 
      Password: '' 
     }; 
    } 
     return { 
     TargetUrl: 'http://dev/', 
     UsePassword: false, 
     User: '', 
     Password: '' 
    }; 
} 

私は本番アプリケーションを構築する場合、私はgetConnectionInfo(true);

呼び出します
関連する問題