Commit c2333f5d044c74c9df82c6c3134681ba21e0d0cd
1 parent
e3cbc932
fix: fix script preview no build
Showing
2 changed files
with
13 additions
and
10 deletions
build/script/build.ts
1 | // #!/usr/bin/env node | 1 | // #!/usr/bin/env node |
2 | 2 | ||
3 | -// import { sh } from 'tasksfile'; | 3 | +import { sh } from 'tasksfile'; |
4 | 4 | ||
5 | import { argv } from 'yargs'; | 5 | import { argv } from 'yargs'; |
6 | import { runBuildConfig } from './buildConf'; | 6 | import { runBuildConfig } from './buildConf'; |
@@ -8,22 +8,25 @@ import { runUpdateHtml } from './updateHtml'; | @@ -8,22 +8,25 @@ import { runUpdateHtml } from './updateHtml'; | ||
8 | import { errorConsole, successConsole } from '../utils'; | 8 | import { errorConsole, successConsole } from '../utils'; |
9 | import { startGzipStyle } from '../plugin/gzip/compress'; | 9 | import { startGzipStyle } from '../plugin/gzip/compress'; |
10 | 10 | ||
11 | -export const runBuild = async () => { | 11 | +export const runBuild = async (preview = false) => { |
12 | try { | 12 | try { |
13 | const argvList = argv._; | 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 | // Generate configuration file | 22 | // Generate configuration file |
22 | if (!argvList.includes('no-conf')) { | 23 | if (!argvList.includes('no-conf')) { |
23 | await runBuildConfig(); | 24 | await runBuildConfig(); |
24 | } | 25 | } |
25 | await runUpdateHtml(); | 26 | await runUpdateHtml(); |
26 | - await startGzipStyle(); | 27 | + if (!preview) { |
28 | + await startGzipStyle(); | ||
29 | + } | ||
27 | successConsole('Vite Build successfully!'); | 30 | successConsole('Vite Build successfully!'); |
28 | } catch (error) { | 31 | } catch (error) { |
29 | errorConsole('Vite Build Error\n' + error); | 32 | errorConsole('Vite Build Error\n' + error); |
build/script/preview.ts
@@ -53,7 +53,7 @@ export const runPreview = async () => { | @@ -53,7 +53,7 @@ export const runPreview = async () => { | ||
53 | }); | 53 | }); |
54 | const { type } = await prompt; | 54 | const { type } = await prompt; |
55 | if (type === BUILD) { | 55 | if (type === BUILD) { |
56 | - await runBuild(); | 56 | + await runBuild(true); |
57 | } | 57 | } |
58 | startApp(); | 58 | startApp(); |
59 | }; | 59 | }; |