npm i -g @angular/cli
ng new app-name
cd app-name
cordova create folder-name tld.company.app-name app-name
cordova platform add platform-name
Add scripts folder in folder-name.
Create a file : prepareAngularApp.js
Content :
const fs = require('fs');
const execSync = require('child_process').execSync;
module.exports = function(context) {
console.log('Building Angular application into "./www" directory');
const basePath = context.opts.projectRoot;
const baseWWW= basePath + '/www';
console.log(execSync(
"ng build --prod --output-hashing none --delete-output-path true --output-path cordova/www/ --base-href .",
{
maxBuffer: 1024*1024,
cwd: basePath + '/..'
}).toString('utf8')
);
var files = fs.readdirSync(baseWWW);
for (var i = 0; i < files.length; i++) {
if (files[i].endsWith('.gz')) {
fs.unlinkSync(baseWWW + '/' + files[i]);
}
}
fs.writeFileSync(baseWWW + '/.gitignore', `# Ignore everything in this directory
*
# Except this file
!.gitignore
`);
};
ng build --prod --output-hashing none --delete-output-path true --output-path cordova/www/ --base-href .
cordova build platform-name
cordova run platform-name --device