Commit c2333f5d044c74c9df82c6c3134681ba21e0d0cd

Authored by vben
1 parent e3cbc932

fix: fix script preview no build

build/script/build.ts
1 1 // #!/usr/bin/env node
2 2  
3   -// import { sh } from 'tasksfile';
  3 +import { sh } from 'tasksfile';
4 4  
5 5 import { argv } from 'yargs';
6 6 import { runBuildConfig } from './buildConf';
... ... @@ -8,22 +8,25 @@ import { runUpdateHtml } from './updateHtml';
8 8 import { errorConsole, successConsole } from '../utils';
9 9 import { startGzipStyle } from '../plugin/gzip/compress';
10 10  
11   -export const runBuild = async () => {
  11 +export const runBuild = async (preview = false) => {
12 12 try {
13 13 const argvList = argv._;
14   - // let cmd = `cross-env NODE_ENV=production vite build`;
15   - // // await run('cross-env', ['NODE_ENV=production', 'vite', 'build']);
16   - // await sh(cmd, {
17   - // async: true,
18   - // nopipe: true,
19   - // });
  14 + if (preview) {
  15 + let cmd = `cross-env NODE_ENV=production vite build`;
  16 + await sh(cmd, {
  17 + async: true,
  18 + nopipe: true,
  19 + });
  20 + }
20 21  
21 22 // Generate configuration file
22 23 if (!argvList.includes('no-conf')) {
23 24 await runBuildConfig();
24 25 }
25 26 await runUpdateHtml();
26   - await startGzipStyle();
  27 + if (!preview) {
  28 + await startGzipStyle();
  29 + }
27 30 successConsole('Vite Build successfully!');
28 31 } catch (error) {
29 32 errorConsole('Vite Build Error\n' + error);
... ...
build/script/preview.ts
... ... @@ -53,7 +53,7 @@ export const runPreview = async () => {
53 53 });
54 54 const { type } = await prompt;
55 55 if (type === BUILD) {
56   - await runBuild();
  56 + await runBuild(true);
57 57 }
58 58 startApp();
59 59 };
... ...