Skip to content

Instantly share code, notes, and snippets.

@jeffwu85182
Created April 10, 2018 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffwu85182/1c39649696eed4c51dffdeb9585a175d to your computer and use it in GitHub Desktop.
Save jeffwu85182/1c39649696eed4c51dffdeb9585a175d to your computer and use it in GitHub Desktop.
buildApp.js
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