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)