Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): plugin config hook supports return promise #2800

Merged
merged 1 commit into from Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/vite/src/node/config.ts
Expand Up @@ -242,14 +242,14 @@ export async function resolveConfig(

// run config hooks
const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins]
userPlugins.forEach((p) => {
for (const p of userPlugins) {
if (p.config) {
const res = p.config(config, configEnv)
const res = await p.config(config, configEnv)
Shinigami92 marked this conversation as resolved.
Show resolved Hide resolved
if (res) {
config = mergeConfig(config, res)
}
}
})
}

// resolve root
const resolvedRoot = normalizePath(
Expand Down
5 changes: 4 additions & 1 deletion packages/vite/src/node/plugin.ts
Expand Up @@ -61,7 +61,10 @@ export interface Plugin extends RollupPlugin {
* Note: User plugins are resolved before running this hook so injecting other
* plugins inside the `config` hook will have no effect.
*/
config?: (config: UserConfig, env: ConfigEnv) => UserConfig | null | void
config?: (
config: UserConfig,
env: ConfigEnv
) => UserConfig | null | void | Promise<UserConfig | null | void>
/**
* Use this hook to read and store the final resolved vite config.
*/
Expand Down