build.ts 814 B

123456789101112131415161718192021222324252627282930
  1. // #!/usr/bin/env node
  2. // import { sh } from 'tasksfile';
  3. import { argv } from 'yargs';
  4. import { runBuildConfig } from './buildConf';
  5. import { runUpdateHtml } from './updateHtml';
  6. import { errorConsole, successConsole, run } from '../utils';
  7. export const runBuild = async () => {
  8. try {
  9. const argvList = argv._;
  10. // let cmd = `cross-env NODE_ENV=production vite build`;
  11. await run('cross-env', ['NODE_ENV=production', 'vite', 'build']);
  12. // await sh(cmd, {
  13. // async: true,
  14. // nopipe: true,
  15. // });
  16. // Generate configuration file
  17. if (!argvList.includes('no-conf')) {
  18. await runBuildConfig();
  19. }
  20. await runUpdateHtml();
  21. successConsole('Vite Build successfully!');
  22. } catch (error) {
  23. errorConsole('Vite Build Error\n' + error);
  24. process.exit(1);
  25. }
  26. };