build.ts 720 B

12345678910111213141516171819202122232425262728
  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 } 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 sh(cmd, {
  12. async: true,
  13. nopipe: true,
  14. });
  15. // Generate configuration file
  16. if (!argvList.includes('no-conf')) {
  17. await runBuildConfig();
  18. }
  19. await runUpdateHtml();
  20. successConsole('Vite Build successfully!');
  21. } catch (error) {
  22. errorConsole('Vite Build Error\n' + error);
  23. process.exit(1);
  24. }
  25. };