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

fix: use server.perEnvironmentStartEndDuringDev #18549

Merged
Merged
Changes from all commits
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
10 changes: 7 additions & 3 deletions packages/vite/src/node/server/pluginContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class EnvironmentPluginContainer {
hookName: H,
context: (plugin: Plugin) => ThisType<FunctionPluginHooks[H]>,
args: (plugin: Plugin) => Parameters<FunctionPluginHooks[H]>,
condition?: (plugin: Plugin) => boolean,
condition?: (plugin: Plugin) => boolean | undefined,
): Promise<void> {
const parallelPromises: Promise<unknown>[] = []
for (const plugin of this.getSortedPlugins(hookName)) {
Expand Down Expand Up @@ -312,14 +312,16 @@ class EnvironmentPluginContainer {
return
}
this._started = true
const config = this.environment.getTopLevelConfig()
this._buildStartPromise = this.handleHookPromise(
this.hookParallel(
'buildStart',
(plugin) => this._getPluginContext(plugin),
() => [this.options as NormalizedInputOptions],
(plugin) =>
this.environment.name === 'client' ||
plugin.perEnvironmentStartEndDuringDev === true,
config.server.perEnvironmentStartEndDuringDev ||
plugin.perEnvironmentStartEndDuringDev,
),
) as Promise<void>
await this._buildStartPromise
Expand Down Expand Up @@ -512,13 +514,15 @@ class EnvironmentPluginContainer {
if (this._closed) return
this._closed = true
await Promise.allSettled(Array.from(this._processesing))
const config = this.environment.getTopLevelConfig()
await this.hookParallel(
'buildEnd',
(plugin) => this._getPluginContext(plugin),
() => [],
(plugin) =>
this.environment.name === 'client' ||
plugin.perEnvironmentStartEndDuringDev !== true,
config.server.perEnvironmentStartEndDuringDev ||
plugin.perEnvironmentStartEndDuringDev,
)
await this.hookParallel(
'closeBundle',
Expand Down