Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: to make config hmr work in windows #364

Merged
merged 2 commits into from
Oct 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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