From fe30349d350ef08bccd56404ccc3e6d6e0a2e156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Fri, 1 Nov 2024 19:09:44 +0900 Subject: [PATCH] fix: use `server.perEnvironmentStartEndDuringDev` (#18549) --- packages/vite/src/node/server/pluginContainer.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts index 521d95b2a3cb4d..06389988114daa 100644 --- a/packages/vite/src/node/server/pluginContainer.ts +++ b/packages/vite/src/node/server/pluginContainer.ts @@ -283,7 +283,7 @@ class EnvironmentPluginContainer { hookName: H, context: (plugin: Plugin) => ThisType, args: (plugin: Plugin) => Parameters, - condition?: (plugin: Plugin) => boolean, + condition?: (plugin: Plugin) => boolean | undefined, ): Promise { const parallelPromises: Promise[] = [] for (const plugin of this.getSortedPlugins(hookName)) { @@ -312,6 +312,7 @@ class EnvironmentPluginContainer { return } this._started = true + const config = this.environment.getTopLevelConfig() this._buildStartPromise = this.handleHookPromise( this.hookParallel( 'buildStart', @@ -319,7 +320,8 @@ class EnvironmentPluginContainer { () => [this.options as NormalizedInputOptions], (plugin) => this.environment.name === 'client' || - plugin.perEnvironmentStartEndDuringDev === true, + config.server.perEnvironmentStartEndDuringDev || + plugin.perEnvironmentStartEndDuringDev, ), ) as Promise await this._buildStartPromise @@ -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',