From 0d2a4d98a857a8ae0a262a0b665f6477c4692636 Mon Sep 17 00:00:00 2001 From: Ray Zane Date: Tue, 25 Oct 2016 17:41:55 -0400 Subject: [PATCH] Allow configuring the webpackHotDevClient with a url as the query parameter. This is how the normal webpack-dev-server/client.js works. This can be configured like so: entry: [ `require.resolve('react-dev-utils/webpackHotDevClient')?http://0.0.0.0:4001`, 'your-entry.js' ] See: https://github.com/webpack/webpack-dev-server/blob/544d97bf4bee3853c84abb8690923bf93fda4fab/client/index.js#L22 --- packages/react-dev-utils/webpackHotDevClient.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index f15fd06f291..9cc2bab635e 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -24,6 +24,15 @@ var formatWebpackMessages = require('./formatWebpackMessages'); var Entities = require('html-entities').AllHtmlEntities; var entities = new Entities(); +var urlParts; +var query = __resourceQuery; // eslint-disable-line + +if (typeof query === "string" && query) { + urlParts = url.parse(query.substr(1)); +} else { + urlParts = window.location; +} + // Color scheme inspired by https://github.com/glenjamin/webpack-hot-middleware var colors = { reset: ['transparent', 'transparent'], @@ -138,9 +147,9 @@ function destroyErrorOverlay() { // Connect to WebpackDevServer via a socket. var connection = new SockJS(url.format({ - protocol: window.location.protocol, - hostname: window.location.hostname, - port: window.location.port, + protocol: urlParts.protocol, + hostname: urlParts.hostname, + port: urlParts.port, // Hardcoded in WebpackDevServer pathname: '/sockjs-node' }));