vben-admin-thin-next/build/script/postBuild.ts

37 lines
908 B
TypeScript
Raw Normal View History

// #!/usr/bin/env node
2020-10-20 21:00:24 +08:00
import { sh } from 'tasksfile';
2020-10-14 21:22:08 +08:00
import { argv } from 'yargs';
import { runBuildConfig } from './buildConf';
// import { runUpdateHtml } from './updateHtml';
import { errorConsole, successConsole } from '../utils';
import { startGzipStyle } from '../vite/plugin/gzip/compress';
2020-10-20 21:00:24 +08:00
export const runBuild = async (preview = false) => {
try {
const argvList = argv._;
2020-10-20 21:00:24 +08:00
if (preview) {
let cmd = `cross-env NODE_ENV=production vite build`;
2020-10-20 21:00:24 +08:00
await sh(cmd, {
async: true,
nopipe: true,
});
}
// Generate configuration file
if (!argvList.includes('no-conf')) {
await runBuildConfig();
}
// await runUpdateHtml();
2020-10-20 21:00:24 +08:00
if (!preview) {
await startGzipStyle();
}
successConsole('Vite Build successfully!');
} catch (error) {
errorConsole('Vite Build Error\n' + error);
process.exit(1);
}
};
2020-10-26 21:45:43 +08:00
runBuild();