Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions packages/bundler-vite/src/resolveViteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export const resolveViteConfig = ({
options: ViteBundlerOptions
isBuild: boolean
isServer: boolean
}): InlineConfig =>
mergeConfig(
}): InlineConfig => {
// generate base vite config
let viteConfig = mergeConfig(
{
clearScreen: false,
configFile: false,
Expand All @@ -43,3 +44,18 @@ export const resolveViteConfig = ({
// some vite options would not take effect inside a plugin, so we still need to merge them here in addition to userConfigPlugin
options.viteOptions ?? {},
)

// allow modifying vite config via `configureVite`
const configureViteResult = options.configureVite?.(
viteConfig,
isServer,
isBuild,
)

// if `configureVite` returns a configuration object, use vite's mergeConfig to merge it
if (configureViteResult) {
viteConfig = mergeConfig(viteConfig, configureViteResult)
}

return viteConfig
}
5 changes: 5 additions & 0 deletions packages/bundler-vite/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ import type { InlineConfig } from 'vite'
export interface ViteBundlerOptions extends BundlerOptions {
viteOptions?: InlineConfig
vuePluginOptions?: VuePluginOptions
configureVite?: (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please help add comments for each options.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

config: InlineConfig,
isServer: boolean,
isBuild: boolean,
) => InlineConfig | void
}
Loading