非代码文件增加Last-Modified头返回
parent
d5dcd44fec
commit
d1e1084ec1
24
lib/dev.js
24
lib/dev.js
|
@ -248,11 +248,27 @@ export default async function createServer(root = '', conf = {}) {
|
|||
|
||||
default:
|
||||
res.setHeader('content-type', MIME_TYPES[ext] || MIME_TYPES.other)
|
||||
let pub_file = join(PUBLIC_DIR, pathname)
|
||||
let source_file = join(SOURCE_DIR, pathname)
|
||||
|
||||
if (fs.isfile(join(PUBLIC_DIR, pathname))) {
|
||||
code = fs.cat(join(PUBLIC_DIR, pathname))
|
||||
} else if (fs.isfile(join(SOURCE_DIR, pathname))) {
|
||||
code = fs.cat(join(SOURCE_DIR, pathname))
|
||||
if (fs.isfile(pub_file)) {
|
||||
code = fs.cat(pub_file)
|
||||
if (code) {
|
||||
let stat = fs.stat(pub_file)
|
||||
res.setHeader(
|
||||
'Last-Modified',
|
||||
new Date(stat.mtime).toGMTString()
|
||||
)
|
||||
}
|
||||
} else if (fs.isfile(source_file)) {
|
||||
code = fs.cat(source_file)
|
||||
if (code) {
|
||||
let stat = fs.stat(source_file)
|
||||
res.setHeader(
|
||||
'Last-Modified',
|
||||
new Date(stat.mtime).toGMTString()
|
||||
)
|
||||
}
|
||||
} else {
|
||||
code = null
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "fite",
|
||||
"type": "module",
|
||||
"version": "0.7.3",
|
||||
"version": "0.7.4",
|
||||
"bin": {
|
||||
"fite": "index.js"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue