Skip to content

Commit db87736

Browse files
committed
account for an hmr protocol different than the vite servers protocol
1 parent f8aa32b commit db87736

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,16 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
169169

170170
const isAddressInfo = (x: string|AddressInfo|null|undefined): x is AddressInfo => typeof x === 'object'
171171
if (isAddressInfo(address)) {
172-
const protocol = server.config.server.https ? 'https' : 'http'
172+
const configHmrProtocol = typeof server.config.server.hmr === 'object' ? server.config.server.hmr.protocol : null
173+
const clientHmrProtocol = configHmrProtocol ? (configHmrProtocol === 'wss' ? 'https' : 'http') : null
174+
const configProtocol = server.config.server.https ? 'https' : 'http'
175+
const protocol = clientHmrProtocol ?? configProtocol
176+
173177
const configHmrHost = typeof server.config.server.hmr === 'object' ? server.config.server.hmr.host : null
174178
const configHost = typeof server.config.server.host === 'string' ? server.config.server.host : null
175179
const serverAddress = address.family === 'IPv6' ? `[${address.address}]` : address.address
176180
const host = configHmrHost ?? configHost ?? serverAddress
181+
177182
viteDevServerUrl = `${protocol}://${host}:${address.port}`
178183
fs.writeFileSync(hotFile, viteDevServerUrl)
179184

0 commit comments

Comments
 (0)