diff --git a/packages/vite/src/node/server/middlewares/indexHtml.ts b/packages/vite/src/node/server/middlewares/indexHtml.ts index bee93f981a1af2..8d746d60286c9f 100644 --- a/packages/vite/src/node/server/middlewares/indexHtml.ts +++ b/packages/vite/src/node/server/middlewares/indexHtml.ts @@ -69,30 +69,27 @@ export function createDevHtmlTransformFn( config.plugins, config.logger, ) + const transformHooks = [ + preImportMapHook(config), + ...preHooks, + htmlEnvHook(config), + devHtmlHook, + ...normalHooks, + ...postHooks, + postImportMapHook(), + ] return ( server: ViteDevServer, url: string, html: string, originalUrl?: string, ): Promise => { - return applyHtmlTransforms( - html, - [ - preImportMapHook(config), - ...preHooks, - htmlEnvHook(config), - devHtmlHook, - ...normalHooks, - ...postHooks, - postImportMapHook(), - ], - { - path: url, - filename: getHtmlFilename(url, server), - server, - originalUrl, - }, - ) + return applyHtmlTransforms(html, transformHooks, { + path: url, + filename: getHtmlFilename(url, server), + server, + originalUrl, + }) } }