From e057a3ae8d76522b6bede3211c5e80d9b9c5ac37 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 16 Feb 2023 19:29:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E5=A4=84=E9=9D=99?= =?UTF-8?q?=E6=80=81=E8=B5=84=E6=BA=90=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/dev.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/dev.js b/lib/dev.js index 7c5af72..de89b06 100644 --- a/lib/dev.js +++ b/lib/dev.js @@ -188,6 +188,8 @@ export default async function createServer(root = '', conf = {}) { } if (fs.isfile(file)) { code = fs.cat(file) + } else if (fs.isfile(join(PUBLIC_DIR, pathname))) { + code = fs.cat(join(PUBLIC_DIR, pathname)) } else { console.clear() console.log(cyan(pathname), red(`not found!!!`)) @@ -218,11 +220,12 @@ export default async function createServer(root = '', conf = {}) { if (fs.isfile(join(PUBLIC_DIR, pathname))) { code = fs.cat(join(PUBLIC_DIR, pathname)) - } else if (fs.isfile(join(SOURCE_DIR, 'assets', pathname))) { - code = fs.cat(join(SOURCE_DIR, 'assets', pathname)) + } else if (fs.isfile(join(SOURCE_DIR, pathname))) { + code = fs.cat(join(SOURCE_DIR, pathname)) } if (code === null) { - console.error(pathname, '文件不存在') + console.clear() + console.log(cyan(pathname), red(`not found!!!`)) res.writeHead(404, 'Not Found') res.end('') return @@ -265,7 +268,7 @@ export default async function createServer(root = '', conf = {}) { }) chokidar - .watch([SOURCE_DIR, join(root, './index.html')]) + .watch([SOURCE_DIR, PUBLIC_DIR, join(root, './index.html')]) .on('all', (act, filePath) => { if (ready) { let file = filePath.slice(SOURCE_DIR.length)