Skip to content

Commit

Permalink
perf: don't recreate html hooks on each transform call (#15579)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jan 16, 2024
1 parent d0f1d2e commit bdb826c
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions packages/vite/src/node/server/middlewares/indexHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> => {
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,
})
}
}

Expand Down

0 comments on commit bdb826c

Please sign in to comment.