fix: cli dist/web path

This commit is contained in:
hypercross 2026-02-26 16:11:56 +08:00
parent 3efc3b59ad
commit 04dfa77eaf
1 changed files with 10 additions and 2 deletions

View File

@ -2,13 +2,21 @@ import type { ServeCommandHandler } from "../types.js";
import { createServer, Server, IncomingMessage, ServerResponse } from "http";
import { readdirSync, statSync, readFileSync, existsSync } from "fs";
import { createReadStream } from "fs";
import { join, resolve, extname, sep, relative } from "path";
import { join, resolve, extname, sep, relative, dirname } from "path";
import { watch } from "chokidar";
import { fileURLToPath } from "url";
interface ContentIndex {
[path: string]: string;
}
/**
* CLI dist
*/
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const distDir = resolve(__dirname, "..", "..", "web");
/**
* MIME
*/
@ -172,7 +180,6 @@ function createRequestHandler(
*/
export const serveCommand: ServeCommandHandler = async (dir, options) => {
const contentDir = resolve(dir);
const distDir = resolve(process.cwd(), "dist/web");
let contentIndex: ContentIndex = {};
// 扫描内容目录生成索引
@ -236,6 +243,7 @@ export const serveCommand: ServeCommandHandler = async (dir, options) => {
server.listen(port, () => {
console.log(`\n开发服务器已启动http://localhost:${port}`);
console.log(`内容目录:${contentDir}`);
console.log(`静态资源目录:${distDir}`);
console.log(`索引文件http://localhost:${port}/__CONTENT_INDEX.json\n`);
});
};