Blame view

build/script/postBuild.ts 908 Bytes
1
2
// #!/usr/bin/env node
3
import { sh } from 'tasksfile';
vben authored
4
5
6
import { argv } from 'yargs';
import { runBuildConfig } from './buildConf';
7
// import { runUpdateHtml } from './updateHtml';
8
import { errorConsole, successConsole } from '../utils';
9
import { startGzipStyle } from '../vite/plugin/gzip/compress';
10
11
export const runBuild = async (preview = false) => {
12
13
  try {
    const argvList = argv._;
14
    if (preview) {
15
      let cmd = `cross-env NODE_ENV=production vite build`;
16
17
18
19
20
      await sh(cmd, {
        async: true,
        nopipe: true,
      });
    }
21
22
23
24
25

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