How can i build an angular2 cli project to build android cordova
I am playing with an angular-cli 2 project, I want to create it for android using cordova build android
how to do this?
I am creating cordova apps using HTML, CSS, JS. I am starting with angular2. I want to know how we build this with cordova.
Please do not contact IONIC, I am aware of this.
+3
source to share
1 answer
so in your angular cli project, Build an assembly using
ng build --prod --base-href .
Now, whatever happens in your dist folder, put it in your www folder, then generate apk / ipa with
cordova build android
To automate the process, you can make changes here.
- to make sure dist is in the cordova www folder, change the dist location in angular-cli.json and point it to the cordova www folder.
this part will be specific
"apps": [{
"root": "src",
"outDir": "dist", //change this line to point to cordova www folder.
- To run ng build --prod --base-href. whenever we create a cordova write a crochet hook in such cordova.
GIST reference: Cordova - Angular CLI Hook
Register this hook in your config.xml file like this
<hook type="before_prepare" src="hooks/buildApp.js"/>
EDIT:
- the base-href command.
+11
source to share