-
-
Save jeffwu85182/1c39649696eed4c51dffdeb9585a175d to your computer and use it in GitHub Desktop.
buildApp.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs-extra'); | |
const execSync = require('child_process').execSync; | |
const path = require('path'); | |
module.exports = function(context) { | |
const basePath = context.opts.projectRoot; | |
const baseWWW = basePath + '/www'; | |
process.chdir('../frontend/'); | |
console.log(`New directory: ${process.cwd()}`); | |
const source = `${process.cwd()}/dist`; | |
const target = `${process.cwd()}/../cordova/www`; | |
// execSync('ng build --base-href ./', { stdio: [0, 1, 2] }); | |
execSync('ng build -env prod --base-href ./', { stdio: [0, 1, 2] }); | |
try { | |
fs.copySync(source, target); | |
console.log('success!'); | |
} catch (err) { | |
console.error(err); | |
} | |
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'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment