2016-07-08 2 views
-1

이 튜토리얼에서 Apache Cordova를 사용하여 호스팅 된 웹 응용 프로그램을 개발하는 데 Visual Studio 2015를 사용하고 있습니다. http://taco.visualstudio.com/en-us/docs/create-a-hosted-app Cordova WebView의 특정 응용 프로그램 URL에 대해이 URL을 여러 개 설정해야합니다 장소 (config.xml, index.html, index.js). 이 URL은 개발 및 프로덕션 환경에 따라 다릅니다. 그리고 프로덕션 용 응용 프로그램을 빌드하기 전에 여러 위치 (config.xml, index.html, index.js)에서 URL을 대체해야합니다. 이 작업을 자동화 할 수 있습니까 (깡패와 타코 팀 빌드 모듈을 통해)?빌드하기 전에 호스트 응용 프로그램 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 config.xml

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);

전화
관련 문제