2020-10-13 01:40:21 +08:00
|
|
|
// #!/usr/bin/env node
|
|
|
|
|
2020-10-14 22:57:52 +08:00
|
|
|
// import { sh } from 'tasksfile';
|
2020-10-14 21:22:08 +08:00
|
|
|
|
2020-10-13 01:40:21 +08:00
|
|
|
import { argv } from 'yargs';
|
|
|
|
import { runBuildConfig } from './buildConf';
|
|
|
|
import { runUpdateHtml } from './updateHtml';
|
2020-10-14 22:57:52 +08:00
|
|
|
import { errorConsole, successConsole, run } from '../utils';
|
2020-10-13 01:40:21 +08:00
|
|
|
|
|
|
|
export const runBuild = async () => {
|
|
|
|
try {
|
|
|
|
const argvList = argv._;
|
2020-10-14 22:57:52 +08:00
|
|
|
// let cmd = `cross-env NODE_ENV=production vite build`;
|
|
|
|
await run('cross-env', ['NODE_ENV=production', 'vite', 'build']);
|
|
|
|
// await sh(cmd, {
|
|
|
|
// async: true,
|
|
|
|
// nopipe: true,
|
|
|
|
// });
|
2020-10-13 01:40:21 +08:00
|
|
|
|
|
|
|
// Generate configuration file
|
|
|
|
if (!argvList.includes('no-conf')) {
|
|
|
|
await runBuildConfig();
|
|
|
|
}
|
|
|
|
await runUpdateHtml();
|
|
|
|
successConsole('Vite Build successfully!');
|
|
|
|
} catch (error) {
|
|
|
|
errorConsole('Vite Build Error\n' + error);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
};
|