diff --git a/lib/dev.js b/lib/dev.js index fb7332e..806101c 100644 --- a/lib/dev.js +++ b/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 } diff --git a/package.json b/package.json index 45bfbdd..5f359b1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "fite", "type": "module", - "version": "0.7.3", + "version": "0.7.4", "bin": { "fite": "index.js" },