From d7ef24909fcad0ca3be77c97be80cf32fa2523f2 Mon Sep 17 00:00:00 2001 From: Kia Ishii Date: Fri, 23 Oct 2020 20:44:11 +0900 Subject: [PATCH] fix: always set `base` to `/` in dev mode to avoid broken links --- src/node/config.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/node/config.ts b/src/node/config.ts index 3df6646c..33dd4084 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -41,6 +41,13 @@ export async function resolveConfig( const userConfig = await resolveUserConfig(root) const site = await resolveSiteData(root) + // force base path to be `/` when it's running in a non-production + // environment. currently, it's hard to implement `base` feature while + // making it work with Vite HMR, and this is an easy workaround. + if (process.env.NODE_ENV !== 'production') { + site.base = '/' + } + // resolve theme path const userThemeDir = resolve(root, 'theme') const themeDir = (await fs.pathExists(userThemeDir))