Skip to content

Commit

Permalink
fix: fix script preview no build
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 20, 2020
1 parent e3cbc93 commit c2333f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions build/script/build.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
// #!/usr/bin/env node

// import { sh } from 'tasksfile';
import { sh } from 'tasksfile';

import { argv } from 'yargs';
import { runBuildConfig } from './buildConf';
import { runUpdateHtml } from './updateHtml';
import { errorConsole, successConsole } from '../utils';
import { startGzipStyle } from '../plugin/gzip/compress';

export const runBuild = async () => {
export const runBuild = async (preview = false) => {
try {
const argvList = argv._;
// let cmd = `cross-env NODE_ENV=production vite build`;
// // await run('cross-env', ['NODE_ENV=production', 'vite', 'build']);
// await sh(cmd, {
// async: true,
// nopipe: true,
// });
if (preview) {
let cmd = `cross-env NODE_ENV=production vite build`;
await sh(cmd, {
async: true,
nopipe: true,
});
}

// Generate configuration file
if (!argvList.includes('no-conf')) {
await runBuildConfig();
}
await runUpdateHtml();
await startGzipStyle();
if (!preview) {
await startGzipStyle();
}
successConsole('Vite Build successfully!');
} catch (error) {
errorConsole('Vite Build Error\n' + error);
Expand Down
2 changes: 1 addition & 1 deletion build/script/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const runPreview = async () => {
});
const { type } = await prompt;
if (type === BUILD) {
await runBuild();
await runBuild(true);
}
startApp();
};

0 comments on commit c2333f5

Please sign in to comment.