wip: serve w/ new impl

pull/198/head
Evan You 4 years ago
parent 9ef7c8de1b
commit 04ed45d250

@ -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"

@ -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}`)
})
}

Loading…
Cancel
Save