From e6af6842a587a07aebb05b6af225fa7eeb5a9207 Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 22 May 2023 18:10:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96css/scss=E5=A4=84=E7=90=86;?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddist=E7=9B=AE=E5=BD=95=E4=B8=8D=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 2 +- lib/prod.js | 18 +++++++++++------- package.json | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index e2f83b2..25125ed 100755 --- a/index.js +++ b/index.js @@ -55,7 +55,7 @@ switch (mode) { .then(function (conf) { let dist = conf.buildDir || 'dist' if (clean && fs.isdir(dist)) { - fs.mkdir(dist) + fs.rm(dist) } compile(WORK_SPACE, dist, conf.default) }) diff --git a/lib/prod.js b/lib/prod.js index 3ff8c94..03713f8 100644 --- a/lib/prod.js +++ b/lib/prod.js @@ -96,6 +96,7 @@ export default function compile(root = '', dist = '', conf = {}) { let code = fs.cat(it.path) code = parseJs(code + '', conf.imports, options) + Es.transform(code, { minify: true }).then(r => { fs.echo(r.code, join(dist, 'assets/', pageDir, it.name)) }) @@ -105,14 +106,17 @@ export default function compile(root = '', dist = '', conf = {}) { case '.scss': case '.css': { - let code = compileScss(it.path) - // if (!it.name.startsWith('assets')) { - // it.name = 'assets/' + it.name - // } - fs.echo( - code, - join(dist, 'assets/', it.name.replace(/\.scss$/, '.css')) + let target = join( + dist, + 'assets/', + it.name.replace(/\.scss$/, '.css') ) + if (it.ext === '.css') { + fs.cp(it.path, target) + } else { + let code = compileScss(it.path) + fs.echo(code, target) + } } break diff --git a/package.json b/package.json index e9a706f..c94d6bd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "fite", "type": "module", - "version": "1.1.4", + "version": "1.1.5", "bin": { "fite": "index.js" },