From 04ed45d250233ff64be28f59614cf904add73208 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 29 Dec 2020 10:21:27 -0500 Subject: [PATCH] wip: serve w/ new impl --- package.json | 2 +- src/node/serve/serve.ts | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index be0df27f..ed3e9877 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "docs-dev": "node ./bin/vitepress dev docs", "docs-debug": "node --inspect-brk ./bin/vitepress dev docs", "docs-build": "yarn build && node ./bin/vitepress build docs", - "docs-serve": "yarn docs-build && node ./bin/vitepress serve --root docs" + "docs-serve": "yarn docs-build && node ./bin/vitepress serve docs" }, "engines": { "node": ">=10.0.0" diff --git a/src/node/serve/serve.ts b/src/node/serve/serve.ts index b51e169f..8f6ed28d 100644 --- a/src/node/serve/serve.ts +++ b/src/node/serve/serve.ts @@ -1,5 +1,5 @@ -import Koa from 'koa' -import koaServe from 'koa-static' +import http from 'http' +import sirv from 'sirv' import { resolveConfig } from '../config' export interface ServeOptions { @@ -11,11 +11,8 @@ export async function serve(options: ServeOptions = {}) { const port = options.port !== undefined ? options.port : 3000 const site = await resolveConfig(options.root) - const app = new Koa() - - app.use(koaServe(site.outDir)) - - app.listen(port) - - console.log(`listening at http://localhost:${port}`) + const server = http.createServer(sirv(site.outDir, { dev: true, etag: true })) + server.listen(port, () => { + console.log(`listening at http://localhost:${port}`) + }) }