build.ts 725 字节
Newer Older
1 2 3
// #!/usr/bin/env node

import { sh } from 'tasksfile';
V
vben 已提交
4

5 6 7 8 9 10 11 12
import { argv } from 'yargs';
import { runBuildConfig } from './buildConf';
import { runUpdateHtml } from './updateHtml';
import { errorConsole, successConsole } from '../utils';

export const runBuild = async () => {
  try {
    const argvList = argv._;
V
vben 已提交
13
    let cmd = `npx cross-env NODE_ENV=production vite build`;
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    await sh(cmd, {
      async: true,
      nopipe: true,
    });

    // 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);
  }
};