|
|
|
|
@ -122,7 +122,7 @@ export async function createVitePressPlugin(
|
|
|
|
|
let siteData = site
|
|
|
|
|
let allDeadLinks: MarkdownCompileResult['deadLinks'] = []
|
|
|
|
|
let config: ResolvedConfig
|
|
|
|
|
let importerMap: Record<string, Set<string>> = {}
|
|
|
|
|
let importerMap: Record<string, Set<string> | undefined> = {}
|
|
|
|
|
|
|
|
|
|
const vitePressPlugin: Plugin = {
|
|
|
|
|
name: 'vitepress',
|
|
|
|
|
@ -248,12 +248,13 @@ export async function createVitePressPlugin(
|
|
|
|
|
configDeps.forEach((file) => server.watcher.add(file))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onFileAddDelete = async (added: boolean, file: string) => {
|
|
|
|
|
const onFileAddDelete = async (added: boolean, _file: string) => {
|
|
|
|
|
const file = slash(_file)
|
|
|
|
|
// restart server on theme file creation / deletion
|
|
|
|
|
if (themeRE.test(slash(file))) {
|
|
|
|
|
if (themeRE.test(file)) {
|
|
|
|
|
siteConfig.logger.info(
|
|
|
|
|
c.green(
|
|
|
|
|
`${path.relative(process.cwd(), file)} ${
|
|
|
|
|
`${path.relative(process.cwd(), _file)} ${
|
|
|
|
|
added ? 'created' : 'deleted'
|
|
|
|
|
}, restarting server...\n`
|
|
|
|
|
),
|
|
|
|
|
@ -271,8 +272,8 @@ export async function createVitePressPlugin(
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!added && importerMap[slash(file)]) {
|
|
|
|
|
delete importerMap[slash(file)]
|
|
|
|
|
if (!added && importerMap[file]) {
|
|
|
|
|
delete importerMap[file]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
server.watcher
|
|
|
|
|
@ -417,7 +418,10 @@ export async function createVitePressPlugin(
|
|
|
|
|
if (importers.length > 0) {
|
|
|
|
|
return [
|
|
|
|
|
...modules,
|
|
|
|
|
...importers.map((id) => server.moduleGraph.getModuleById(id))
|
|
|
|
|
...importers.map((id) => {
|
|
|
|
|
clearCache(id)
|
|
|
|
|
return server.moduleGraph.getModuleById(id)
|
|
|
|
|
})
|
|
|
|
|
].filter(Boolean) as ModuleNode[]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|