From 95bd7e1a225f56c3c2b7ac5acbb647b2f6a5dcd5 Mon Sep 17 00:00:00 2001 From: CHOYSEN Date: Sat, 14 Aug 2021 15:15:52 +0800 Subject: [PATCH] fix: to make config hmr work in window --- src/node/config.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node/config.ts b/src/node/config.ts index 4f8ebdd78cae..5346f996b7be 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -2,7 +2,7 @@ import path from 'path' import fs from 'fs-extra' import chalk from 'chalk' import globby from 'globby' -import { AliasOptions, UserConfig as ViteConfig } from 'vite' +import { normalizePath, AliasOptions, UserConfig as ViteConfig } from 'vite' import { Options as VuePluginOptions } from '@vitejs/plugin-vue' import { SiteData, HeadConfig, LocaleConfig } from './shared' import { resolveAliases, APP_PATH, DEFAULT_THEME_PATH } from './alias' @@ -60,7 +60,7 @@ export interface SiteConfig { } 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() @@ -116,7 +116,7 @@ export async function resolveUserConfig(root: string): Promise { 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: UserConfig | (() => UserConfig) = hasUserConfig ? require(configPath) : {}