提交 | 用户 | age
|
bb3b8f
|
1 |
// #!/usr/bin/env node |
N |
2 |
|
c2333f
|
3 |
import { sh } from 'tasksfile'; |
77db3d
|
4 |
|
bb3b8f
|
5 |
import { argv } from 'yargs'; |
N |
6 |
import { runBuildConfig } from './buildConf'; |
|
7 |
import { runUpdateHtml } from './updateHtml'; |
6211ba
|
8 |
import { errorConsole, successConsole } from '../utils'; |
8a1bfd
|
9 |
import { startGzipStyle } from '../plugin/gzip/compress'; |
bb3b8f
|
10 |
|
c2333f
|
11 |
export const runBuild = async (preview = false) => { |
bb3b8f
|
12 |
try { |
N |
13 |
const argvList = argv._; |
c2333f
|
14 |
if (preview) { |
2be166
|
15 |
let cmd = `npm run build`; |
c2333f
|
16 |
await sh(cmd, { |
V |
17 |
async: true, |
|
18 |
nopipe: true, |
|
19 |
}); |
|
20 |
} |
bb3b8f
|
21 |
|
N |
22 |
// Generate configuration file |
|
23 |
if (!argvList.includes('no-conf')) { |
|
24 |
await runBuildConfig(); |
|
25 |
} |
|
26 |
await runUpdateHtml(); |
c2333f
|
27 |
if (!preview) { |
V |
28 |
await startGzipStyle(); |
|
29 |
} |
bb3b8f
|
30 |
successConsole('Vite Build successfully!'); |
N |
31 |
} catch (error) { |
|
32 |
errorConsole('Vite Build Error\n' + error); |
|
33 |
process.exit(1); |
|
34 |
} |
|
35 |
}; |
2be166
|
36 |
runBuild(); |