2017-12-14 2 views
1

Cordova 플랫폼을 추가 할 때마다 cordova는 인터넷에서 지정된 플랫폼 용 코도바 파일을 가져옵니다. 이러한 파일을 로컬 디렉토리에 다운로드하고 코드 바가 원격 파일 대신 사용하도록 할 수 있습니까? 어쩌면 마법의 Env 변수가 있을까요?"cordova platform add <platform>"을 실행할 때 원격 다운로드를 방지하기 위해 cordova의 플랫폼 프로젝트를 캐시하는 방법은 무엇입니까?

+0

아니요, 불가능 –

답변

0

당신은 GitHub의에서 로컬 플랫폼을 복제하고 대신 NPM/github의에서 추가의 경로에서 추가,하지만 당신은처럼 추가해야합니다 당신은

cordova platform add <platform> 

을 사용할 수 있습니다

cordova platform add /path/to/platform/ 
0

나는 이것이 내 질문의 범위를 벗어난 것임을 알고 있지만 나는 다른 사람들에게 유용 할 수 있으므로 게시하는 것이 가치 있다고 생각한다.

다음 안내는 로컬/오프라인 코드바 환경을 설정하는 방법을 설명합니다. 이렇게하면 시간을 절약 할 수 있습니다. 나처럼 다른 플랫폼에서 많은 앱을 빌드하고 배포 할 수 있습니다. 보너스로 나는 또한 안드로이드가 더 많은 시간이 걸리는 작업 인 로컬 gradle을 설정하는 방법을 설명합니다.

mkdir local_cordova && cd local_cordova && npm init 
# confirm all stuff 
npm install cordova-fetch 
touch download-cordova-ios.js 
touch download-cordova-android.js 
open download-cordova-ios.js 
# paste the lines below: 

var fetch = require('cordova-fetch'); 
var spec = '[email protected]~4.5.1'; 
/* Version can be ommited */ 
var dest = './bin/ios' 
var opts = { save: true } fetch(spec, dest, opts); 

# save the file open download-cordova-android.js 
# paste the lines below 

# Now open the android file and do the same 
open download-cordova-android.js 


var fetch = require('cordova-fetch'); 
var spec = '[email protected]~6.3.0'; 
/* Version can be ommited */ 
var dest = './bin/android' 
var opts = { save: true } 
fetch(spec, dest, opts); 


# Now run the node command and wait for the script to complete 
node download-cordova-android.js && node download-cordova-ios.js 

# Now lets create some environment variables for each our local cordova platforms. 
vim ~/.bash_profile 
# add the following lines 
export CORDOVA_DROID="/path/to/your/cordova/cordova-fetch/bin/android/node_modules/cordova-android"; 

export CORDOVA_IOS="/path/to/your/cordova/cordova-fetch/bin/ios/node_modules/cordova-ios"; 

source ~/.bash_profile 

cd ~/Desktop/ 
cordova create test-app com.test.app test-app && cd test-app 
cordova platform add $CORDOVA_DROID 
cordova platform add $CORDOVA_IOS 

cordova build android 
#In a normal situation cordova will download a gradle which is 60+MB. Since this operation can take a while I suggest you to setup an environment variable that will save you lots of time. 

# Go to https://services.gradle.org/distributions/ 
# and find the distribution that fits your needs 
# mine was gradle-4.0.2-all.zip 
# download it and place it somewhere in your disk. Consider a location that can be persisted over time. 


vim ~/.bash_profile 
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=file:///path/to/your/gradle-4.0-all.zip 

# That's all 
관련 문제