feat(build): allow overriding vite config loading (#2750)

pull/2753/head
Divyansh Singh 11 months ago committed by GitHub
parent 0f421d7222
commit 1bed154612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,7 @@ import {
normalizePath, normalizePath,
type BuildOptions, type BuildOptions,
type Rollup, type Rollup,
type UserConfig as ViteUserConfig type InlineConfig as ViteInlineConfig
} from 'vite' } from 'vite'
import { APP_PATH } from '../alias' import { APP_PATH } from '../alias'
import type { SiteConfig } from '../config' import type { SiteConfig } from '../config'
@ -50,7 +50,9 @@ export async function bundle(
// resolve options to pass to vite // resolve options to pass to vite
const { rollupOptions } = options const { rollupOptions } = options
const resolveViteConfig = async (ssr: boolean): Promise<ViteUserConfig> => ({ const resolveViteConfig = async (
ssr: boolean
): Promise<ViteInlineConfig> => ({
root: config.srcDir, root: config.srcDir,
cacheDir: config.cacheDir, cacheDir: config.cacheDir,
base: config.site.base, base: config.site.base,
@ -136,7 +138,8 @@ export async function bundle(
}) })
} }
} }
} },
configFile: config.vite?.configFile
}) })
let clientResult!: Rollup.RollupOutput | null let clientResult!: Rollup.RollupOutput | null

@ -23,6 +23,7 @@ export async function createServer(
cacheDir: config.cacheDir, cacheDir: config.cacheDir,
plugins: await createVitePressPlugin(config, false, {}, {}, recreateServer), plugins: await createVitePressPlugin(config, false, {}, {}, recreateServer),
server: serverOptions, server: serverOptions,
customLogger: config.logger customLogger: config.logger,
configFile: config.vite?.configFile
}) })
} }

@ -83,7 +83,7 @@ export interface UserConfig<ThemeConfig = any>
/** /**
* Vite config * Vite config
*/ */
vite?: ViteConfig vite?: ViteConfig & { configFile?: string | false }
/** /**
* Configure the scroll offset when the theme has a sticky header. * Configure the scroll offset when the theme has a sticky header.

Loading…
Cancel
Save