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