Skip to content

Commit

Permalink
feat(build): allow overriding vite config loading (#2750)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd authored Aug 8, 2023
1 parent 0f421d7 commit 1bed154
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/node/build/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -50,7 +50,9 @@ export async function bundle(
// resolve options to pass to vite
const { rollupOptions } = options

const resolveViteConfig = async (ssr: boolean): Promise<ViteUserConfig> => ({
const resolveViteConfig = async (
ssr: boolean
): Promise<ViteInlineConfig> => ({
root: config.srcDir,
cacheDir: config.cacheDir,
base: config.site.base,
Expand Down Expand Up @@ -136,7 +138,8 @@ export async function bundle(
})
}
}
}
},
configFile: config.vite?.configFile
})

let clientResult!: Rollup.RollupOutput | null
Expand Down
3 changes: 2 additions & 1 deletion src/node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
2 changes: 1 addition & 1 deletion src/node/siteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export interface UserConfig<ThemeConfig = any>
/**
* Vite config
*/
vite?: ViteConfig
vite?: ViteConfig & { configFile?: string | false }

/**
* Configure the scroll offset when the theme has a sticky header.
Expand Down

0 comments on commit 1bed154

Please sign in to comment.