Skip to content

Commit

Permalink
fix: avoid error when requesting non-existing md file
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 2, 2020
1 parent 4a8388e commit e77ea63
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { resolveConfig, SiteConfig, resolveSiteData } from './config'
import { createMarkdownToVueRenderFn } from './markdownToVue'
import { APP_PATH, SITE_DATA_REQUEST_PATH } from './resolver'
import { existsSync } from 'fs'

const debug = require('debug')('vitepress:serve')
const debugHmr = require('debug')('vitepress:hmr')
Expand Down Expand Up @@ -85,6 +86,10 @@ function createVitePressPlugin({
// handle .md -> vue transforms
if (ctx.path.endsWith('.md')) {
const file = resolver.requestToFile(ctx.path)
if (!existsSync(file)) {
return next()
}

await cachedRead(ctx, file)

// let vite know this is supposed to be treated as vue file
Expand Down

0 comments on commit e77ea63

Please sign in to comment.