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-dev": "node ./bin/vitepress dev docs",
"docs-debug": "node --inspect-brk ./bin/vitepress dev docs", "docs-debug": "node --inspect-brk ./bin/vitepress dev docs",
"docs-build": "yarn build && node ./bin/vitepress build 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": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"

@ -1,5 +1,5 @@
import Koa from 'koa' import http from 'http'
import koaServe from 'koa-static' import sirv from 'sirv'
import { resolveConfig } from '../config' import { resolveConfig } from '../config'
export interface ServeOptions { export interface ServeOptions {
@ -11,11 +11,8 @@ export async function serve(options: ServeOptions = {}) {
const port = options.port !== undefined ? options.port : 3000 const port = options.port !== undefined ? options.port : 3000
const site = await resolveConfig(options.root) const site = await resolveConfig(options.root)
const app = new Koa() const server = http.createServer(sirv(site.outDir, { dev: true, etag: true }))
server.listen(port, () => {
app.use(koaServe(site.outDir)) console.log(`listening at http://localhost:${port}`)
})
app.listen(port)
console.log(`listening at http://localhost:${port}`)
} }

Loading…
Cancel
Save