修复一处静态资源路径问题
parent
304841a9a0
commit
e057a3ae8d
11
lib/dev.js
11
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)
|
||||
|
|
Loading…
Reference in New Issue