Skip to content

Commit b989c42

Browse files
authored
feat: apply some middlewares before configurePreviewServer hook (#20224)
1 parent f5cc4c0 commit b989c42

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/vite/src/node/preview.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,6 @@ export async function preview(
195195

196196
setupSIGTERMListener(closeServerAndExit)
197197

198-
// apply server hooks from plugins
199-
const configurePreviewServerContext = new BasicMinimalPluginContext(
200-
{ ...basePluginContextMeta, watchMode: false },
201-
config.logger,
202-
)
203-
const postHooks: ((() => void) | void)[] = []
204-
for (const hook of config.getSortedPluginHooks('configurePreviewServer')) {
205-
postHooks.push(await hook.call(configurePreviewServerContext, server))
206-
}
207-
208198
// cors
209199
const { cors } = config.preview
210200
if (cors !== false) {
@@ -218,6 +208,16 @@ export async function preview(
218208
app.use(hostValidationMiddleware(allowedHosts, true))
219209
}
220210

211+
// apply server hooks from plugins
212+
const configurePreviewServerContext = new BasicMinimalPluginContext(
213+
{ ...basePluginContextMeta, watchMode: false },
214+
config.logger,
215+
)
216+
const postHooks: ((() => void) | void)[] = []
217+
for (const hook of config.getSortedPluginHooks('configurePreviewServer')) {
218+
postHooks.push(await hook.call(configurePreviewServerContext, server))
219+
}
220+
221221
// proxy
222222
const { proxy } = config.preview
223223
if (proxy) {

0 commit comments

Comments
 (0)