use cachedRead

pull/1/head
Evan You 5 years ago
parent 24bac77eec
commit 3196f90a56

@ -1,5 +1,4 @@
import path from 'path' import path from 'path'
import { promises as fs } from 'fs'
import { import {
createServer as createViteServer, createServer as createViteServer,
cachedRead, cachedRead,
@ -44,7 +43,7 @@ const VitePressPlugin: Plugin = ({ app, root, watcher, resolver }) => {
// hot reload .md files as .vue files // hot reload .md files as .vue files
watcher.on('change', async (file) => { watcher.on('change', async (file) => {
if (file.endsWith('.md')) { if (file.endsWith('.md')) {
const content = await fs.readFile(file, 'utf-8') const content = await cachedRead(null, file)
watcher.handleVueReload(file, Date.now(), markdownToVue(content)) watcher.handleVueReload(file, Date.now(), markdownToVue(content))
} }
}) })

Loading…
Cancel
Save