Skip to content

Commit

Permalink
fix: make config hmr work in window (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
CHOYSEN authored Oct 7, 2021
1 parent 49ddb1f commit 58663bb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs-extra'
import chalk from 'chalk'
import globby from 'globby'
import {
normalizePath,
AliasOptions,
UserConfig as ViteConfig,
mergeConfig as mergeViteConfig
Expand Down Expand Up @@ -75,7 +76,7 @@ export interface SiteConfig<ThemeConfig = any> {
}

const resolve = (root: string, file: string) =>
path.resolve(root, `.vitepress`, file)
normalizePath(path.resolve(root, `.vitepress`, file))

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

0 comments on commit 58663bb

Please sign in to comment.