From 681775a13c0b8dddeda17545bf3fc1bfb2597d74 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 26 Jan 2023 16:11:24 +0800 Subject: [PATCH] build: fix build script --- scripts/build.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index 29938294f..090995fc9 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -91,7 +91,7 @@ async function build(target) { } // if building a specific format, do not remove dist. - if (!formats) { + if (!formats && existsSync(`${pkgDir}/dist`)) { await fs.rm(`${pkgDir}/dist`, { recursive: true }) } @@ -192,7 +192,7 @@ function checkFileSize(filePath) { const gzipped = gzipSync(file) const gzippedSize = (gzipped.length / 1024).toFixed(2) + 'kb' const compressed = compress(file) - const compressedSize = (compressed.length / 1024).toFixed(2) + 'kb' + const compressedSize = (compressed?.length || 0 / 1024).toFixed(2) + 'kb' console.log( `${chalk.gray( chalk.bold(path.basename(filePath))