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

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

5 6 7
import { argv } from 'yargs';
import { runBuildConfig } from './buildConf';
import { runUpdateHtml } from './updateHtml';
8
import { errorConsole, successConsole } from '../utils';
V
vben 已提交
9
import { startGzipStyle } from '../plugin/gzip/compress';
10 11 12 13

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

    // Generate configuration file
    if (!argvList.includes('no-conf')) {
      await runBuildConfig();
    }
    await runUpdateHtml();
V
vben 已提交
26
    await startGzipStyle();
27 28 29 30 31 32
    successConsole('Vite Build successfully!');
  } catch (error) {
    errorConsole('Vite Build Error\n' + error);
    process.exit(1);
  }
};