From 78ba36b913a48510cc81dc3c93bd305adf841eef Mon Sep 17 00:00:00 2001 From: warjiang <1096409085@qq.com> Date: Thu, 19 Jan 2023 14:24:51 +0800 Subject: [PATCH] fix: assets build script Signed-off-by: warjiang <1096409085@qq.com> --- scripts/build.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 38acc9a7..8d0e26b7 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -97,7 +97,7 @@ async function getEntryArray(source) { return (await Promise.all(array)).flat(1); } - +const fontPath = "static/app/DroidSansMono_v1.ttf"; async function assets() { const entryArray = (await getEntryArray("static")).map((file) => { if (file.endsWith(".css")) { @@ -105,12 +105,16 @@ async function assets() { } return ""; }); - - await startBuild("css", [...entryArray, "--target=chrome89"]); - - fs.createReadStream("static/app/DroidSansMono_v1.ttf").pipe( - fs.createWriteStream("dist/static/app/DroidSansMono_v1.ttf") - ); + // build like `npx esbuild --target=chrome89 --outdir=dist --bundle --sourcemap` will block the process of build + if (entryArray.length > 0) { + await startBuild("css", [...entryArray, "--target=chrome89"]); + } + // pre check fontPath + if(fs.existsSync(fontPath)) { + fs.createReadStream(fontPath).pipe( + fs.createWriteStream(`dist/${fontPath}`) + ); + } } async function html() {