feat(cli): optimzie clean

This commit is contained in:
陈嘉涵 2019-11-29 10:01:25 +08:00
parent cc26929ebc
commit a0fd87a0d1
2 changed files with 28 additions and 9 deletions

View File

@ -67,13 +67,11 @@ function buildPackage(isMinify: boolean) {
});
}
export async function build() {
clean();
export async function buildESModuleOutputs() {
await copy(SRC_DIR, ES_DIR);
await copy(SRC_DIR, LIB_DIR);
start('Build esmodule outputs');
try {
setModuleEnv('esmodule');
await compileDir(ES_DIR);
@ -81,8 +79,13 @@ export async function build() {
} catch (err) {
error('Build esmodule outputs');
}
}
export async function buildCommonjsOutputs() {
await copy(SRC_DIR, LIB_DIR);
start('Build commonjs outputs');
try {
setModuleEnv('commonjs');
await compileDir(LIB_DIR);
@ -90,16 +93,22 @@ export async function build() {
} catch (err) {
error('Build commonjs outputs');
}
}
export async function buildStyleEntry() {
start('Build style entry');
try {
genStyleEntry();
success('Build style entry');
} catch (err) {
error('Build style entry');
}
}
export async function buildPackedOutputs() {
start('Build packed outputs');
try {
genPackageEntry();
await buildPackage(false);
@ -109,3 +118,11 @@ export async function build() {
error('Build packed outputs');
}
}
export async function build() {
await clean();
await buildESModuleOutputs();
await buildCommonjsOutputs();
await buildStyleEntry();
await buildPackedOutputs();
}

View File

@ -1,8 +1,10 @@
import { emptyDirSync } from 'fs-extra';
import { emptyDir } from 'fs-extra';
import { ES_DIR, LIB_DIR, DIST_DIR } from '../common/constant';
export function clean() {
emptyDirSync(ES_DIR);
emptyDirSync(LIB_DIR);
emptyDirSync(DIST_DIR);
export async function clean() {
await Promise.all([
emptyDir(ES_DIR),
emptyDir(LIB_DIR),
emptyDir(DIST_DIR)
]);
}