Skip to content

Commit

Permalink
fix(hmr): importMetaUrl.port should be used when HMR server is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
naruaway committed Dec 26, 2022
1 parent 13ac37d commit 2d4a5d9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vite/src/node/plugins/clientInjections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {
const protocol = hmrConfig?.protocol || null
const timeout = hmrConfig?.timeout || 30000
const overlay = hmrConfig?.overlay !== false
const isHmrServerSpecified = !!hmrConfig?.server

// hmr.clientPort -> hmr.port
// -> (24678 if middleware mode) -> new URL(import.meta.url).port
// -> (24678 if middleware mode and HMR server is not specified) -> new URL(import.meta.url).port
let port = hmrConfig?.clientPort || hmrConfig?.port || null
if (config.server.middlewareMode) {
if (config.server.middlewareMode && !isHmrServerSpecified) {
port ||= 24678
}

Expand Down

0 comments on commit 2d4a5d9

Please sign in to comment.