Skip to content

Commit

Permalink
fix(hmr): __HMR_PORT__ should not be 'undefined'
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jun 24, 2022
1 parent cd59ee4 commit e647e49
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/vite/src/node/plugins/clientInjections.ts
Expand Up @@ -26,11 +26,9 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {

// hmr.clientPort -> hmr.port
// -> (24678 if middleware mode) -> new URL(import.meta.url).port
let port = hmrConfig
? String(hmrConfig.clientPort || hmrConfig.port)
: null
let port = hmrConfig?.clientPort || hmrConfig?.port || null
if (config.server.middlewareMode) {
port ||= '24678'
port ||= 24678
}

const devBase = config.base
Expand All @@ -50,7 +48,7 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {
.replace(`__DEFINES__`, serializeDefine(config.define || {}))
.replace(`__HMR_PROTOCOL__`, JSON.stringify(protocol))
.replace(`__HMR_HOSTNAME__`, JSON.stringify(host))
.replace(`__HMR_PORT__`, JSON.stringify(port))
.replace(`__HMR_PORT__`, JSON.stringify(String(port)))
.replace(`__HMR_DIRECT_TARGET__`, JSON.stringify(directTarget))
.replace(`__HMR_BASE__`, JSON.stringify(hmrBase))
.replace(`__HMR_TIMEOUT__`, JSON.stringify(timeout))
Expand Down

0 comments on commit e647e49

Please sign in to comment.