Skip to content

Commit

Permalink
fix: resolvedUrls is null in plugin's configureServer after server re…
Browse files Browse the repository at this point in the history
…start (#15450)
  • Loading branch information
XiSenao authored Jan 10, 2024
1 parent 21a52e6 commit 653a48c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,17 @@ export async function _createServer(
_shortcutsOptions: undefined,
}

// maintain consistency with the server instance after restarting.
const reflexServer = new Proxy(server, {
get: (_, property: keyof ViteDevServer) => {
return server[property]
},
set: (_, property: keyof ViteDevServer, value: never) => {
server[property] = value
return true
},
})

if (!middlewareMode) {
exitProcess = async () => {
try {
Expand Down Expand Up @@ -717,7 +728,7 @@ export async function _createServer(
// apply server configuration hooks from plugins
const postHooks: ((() => void) | void)[] = []
for (const hook of config.getSortedPluginHooks('configureServer')) {
postHooks.push(await hook(server))
postHooks.push(await hook(reflexServer))
}

// Internal middlewares ------------------------------------------------------
Expand Down

0 comments on commit 653a48c

Please sign in to comment.