I'm using webpack/react-starter and I'm trying to test using a mobile device connected to the same LAN as my development machine. So instead of putting in localhost:3000 I put the IP 192.168.X.X:3000 into my mobile browser.
What is the best practice for this since mobile won't know be able to evaluate a script tag with localhost? I put this hacky script in the html that gets served in dev but this feels wrong.
<script>
//inserts new script tag with localhost replaced by ip
if('ontouchstart' in window){
var ipRegex = /([0-9]{3}\.){2}[0-9]{1,3}\.[0-9]{1,3}/;
var ip = window.location.href.match(ipRegex)[0];
var url = Array.prototype.shift.call(document.getElementsByTagName('script')).getAttribute('src');
var newScript = document.createElement('script');
newScript.src=url.replace('localhost',ip);
document.body.appendChild(newScript);
}
</script>
This fetches down the bundle but socket.io can't connect to webpack-dev-server [Error] Failed to load resource: Could not connect to the server. (socket.io, line 0)
which won't let me use HMR. What do normal people do in this case?