From 135bced616d47f4171146795adb97109759f95c4 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 23 Mar 2023 14:33:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=B9=E9=94=99=E5=A4=84?= =?UTF-8?q?=E7=90=86,=E9=81=BF=E5=85=8D=E7=A8=8B=E5=BA=8F=E5=B4=A9?= =?UTF-8?q?=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.js | 17 ++++++++++------- lib/utils.js | 1 + package.json | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index d25abf1..ede1a1e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -47,14 +47,17 @@ export default function compile(root = '', isProd = false, es) { { let code = fs.cat(filePath).toString() console.log('编译 %s ...', blue(file)) - code = Es.transformSync(code, OPTIONS).code.replace( - /css`([\w\W]*?)`/g, - function (m, scss) { - scss = compileScss(scss) - return `css\`${scss}\`` - } - ) + try { + code = Es.transformSync(code, OPTIONS).code + } catch (err) { + console.log('compile scss: ', file) + console.error(err) + } + code = code.replace(/css`([\w\W]*?)`/g, function (m, scss) { + scss = compileScss(scss) + return `css\`${scss}\`` + }) fs.echo(code, target) } break diff --git a/lib/utils.js b/lib/utils.js index bf442f8..6fe1590 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -24,5 +24,6 @@ export function compileScss(file, mini = true) { } catch (err) { console.log('compile scss: ', file) console.error(err) + return '' } } diff --git a/package.json b/package.json index 020e72c..a8ae1a8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@bd/wcui-cli", "type": "module", - "version": "1.1.0", + "version": "1.2.0", "bin": { "wcui-cli": "index.js" },