From 1bed154612661ac3783558cf82a7e94832ee4ff8 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:18:12 +0530 Subject: [PATCH] feat(build): allow overriding vite config loading (#2750) --- src/node/build/bundle.ts | 9 ++++++--- src/node/server.ts | 3 ++- src/node/siteConfig.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/node/build/bundle.ts b/src/node/build/bundle.ts index c8e581428bf7..ed7283909566 100644 --- a/src/node/build/bundle.ts +++ b/src/node/build/bundle.ts @@ -6,7 +6,7 @@ import { normalizePath, type BuildOptions, type Rollup, - type UserConfig as ViteUserConfig + type InlineConfig as ViteInlineConfig } from 'vite' import { APP_PATH } from '../alias' import type { SiteConfig } from '../config' @@ -50,7 +50,9 @@ export async function bundle( // resolve options to pass to vite const { rollupOptions } = options - const resolveViteConfig = async (ssr: boolean): Promise => ({ + const resolveViteConfig = async ( + ssr: boolean + ): Promise => ({ root: config.srcDir, cacheDir: config.cacheDir, base: config.site.base, @@ -136,7 +138,8 @@ export async function bundle( }) } } - } + }, + configFile: config.vite?.configFile }) let clientResult!: Rollup.RollupOutput | null diff --git a/src/node/server.ts b/src/node/server.ts index ebf0aedf27be..42ebbc9c543e 100644 --- a/src/node/server.ts +++ b/src/node/server.ts @@ -23,6 +23,7 @@ export async function createServer( cacheDir: config.cacheDir, plugins: await createVitePressPlugin(config, false, {}, {}, recreateServer), server: serverOptions, - customLogger: config.logger + customLogger: config.logger, + configFile: config.vite?.configFile }) } diff --git a/src/node/siteConfig.ts b/src/node/siteConfig.ts index 402fb608d427..4607e710f57f 100644 --- a/src/node/siteConfig.ts +++ b/src/node/siteConfig.ts @@ -83,7 +83,7 @@ export interface UserConfig /** * Vite config */ - vite?: ViteConfig + vite?: ViteConfig & { configFile?: string | false } /** * Configure the scroll offset when the theme has a sticky header.