postBuild.ts 888 B

12345678910111213141516171819202122232425262728293031323334
  1. // #!/usr/bin/env node
  2. import { runBuildConfig } from './buildConf';
  3. import chalk from 'chalk';
  4. const fs = require('fs');
  5. import pkg from '../../package.json';
  6. function removeFile(filename) {
  7. fs.unlink(filename, (err) => {
  8. if (err) {
  9. console.error('删除本地配置文件:', err);
  10. } else {
  11. console.log(`删除本地配置文件: ${filename} 成功!`);
  12. }
  13. });
  14. }
  15. export const runBuild = async () => {
  16. try {
  17. const argvList = process.argv.splice(2);
  18. // Generate configuration file
  19. if (!argvList.includes('disabled-config')) {
  20. runBuildConfig();
  21. }
  22. console.log(`✨ ${chalk.cyan(`[${pkg.name}]`)}` + ' - build successfully!');
  23. // removeFile('./target/dist/_app.config.js');
  24. } catch (error) {
  25. console.log(chalk.red('vite build error:\n' + error));
  26. process.exit(1);
  27. }
  28. };
  29. runBuild();