forked from lctoolsweb/DanhengWebTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
34 lines (24 loc) · 875 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { exec } = require('child_process');
const gradient = require('gradient-string');
const startTime = new Date();
console.log(gradient.retro('✨✨Starting production build...'));
const buildProcess = exec('vite build --mode production', (error, stdout, stderr) => {
if (error) {
console.error(`Build failed with error: ${stderr}`);
process.exit(1);
}
const endTime = new Date();
const buildTime = (endTime - startTime) / 1000;
console.log(stdout);
console.log(gradient.retro(`🎉打包完成,用时 ${buildTime} 秒,击败了全国99%的用户`));
process.exit(0);
});
buildProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
buildProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
buildProcess.on('close', (code) => {
console.log(`Child process exited with code ${code}`);
});