Skip to content

Commit 58663bb

Browse files
authored
fix: make config hmr work in window (#364)
1 parent 49ddb1f commit 58663bb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/node/config.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import fs from 'fs-extra'
33
import chalk from 'chalk'
44
import globby from 'globby'
55
import {
6+
normalizePath,
67
AliasOptions,
78
UserConfig as ViteConfig,
89
mergeConfig as mergeViteConfig
@@ -75,7 +76,7 @@ export interface SiteConfig<ThemeConfig = any> {
7576
}
7677

7778
const resolve = (root: string, file: string) =>
78-
path.resolve(root, `.vitepress`, file)
79+
normalizePath(path.resolve(root, `.vitepress`, file))
7980

8081
export async function resolveConfig(
8182
root: string = process.cwd()
@@ -127,7 +128,7 @@ export async function resolveUserConfig(root: string): Promise<UserConfig> {
127128
const configPath = resolve(root, 'config.js')
128129
const hasUserConfig = await fs.pathExists(configPath)
129130
// always delete cache first before loading config
130-
delete require.cache[configPath]
131+
delete require.cache[require.resolve(configPath)]
131132
const userConfig: RawConfigExports = hasUserConfig ? require(configPath) : {}
132133
if (hasUserConfig) {
133134
debug(`loaded config at ${chalk.yellow(configPath)}`)

0 commit comments

Comments
 (0)