-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow changing socket.io-path via query string #240
Conversation
Does this allow changing the domain? It's hard to test in VM where I use |
@kentor That already works, this allows changing the path too. |
Allow changing socket.io-path via query string
Thanks |
This destroys HMR for us. Using First it says Our entry is |
Hmm that's an interesting edge-case, you want to set the port but not the host? |
That's correct. We always know the port as that's the port of |
It seems pretty clear to me that Anyway, I imagine the correct approach here would be to special-case cc @sokra |
We should be able to use |
@SimenB True, in that case then it's really a bug in PS: If |
Hmm, it seems EDIT: It still makes sense to look into what's going on here, especially if the parsing is actually a bug in nodejs. |
Using Edit: I'll have to test on a WIndows machine tomorrow, will report back. |
Specify what? The entry? webpackConfig.entry = [
'webpack-dev-server/client?http://0.0.0.0:3030',
'webpack/hot/only-dev-server',
path.join(__dirname, 'js/app.js')
]; |
@SimenB |
Ah, ok. Makes sense 😄 |
@SimenB Also, FYI nodejs/node#2929 (comment) |
@SimenB That works for connecting to the socket. But what do you specify as the |
@kentor |
@SimenB The final URL is really funky, including encoded chars (which seems to indicate an URL being encoded as a hostname inside an URL) ... what have you written in your config? I'm assuming the URL you are visiting is https://github.com/webpack/webpack-dev-server/blob/master/client/index.js#L13 |
Entry is still |
@SimenB Hmm, I don't see how that ends up being translated to what you printscreened above... could you perhaps put some // on line 10
console.log(urlParts);
console.log(window.location.hostname);
console.log(
url.format({
protocol: urlParts.protocol,
auth: urlParts.auth,
hostname: (urlParts.hostname === '0.0.0.0') ? window.location.hostname : urlParts.hostname,
port: urlParts.port
})
); |
Also: console.log(__resourceQuery); |
Using console.log(__resourceQuery);
console.log(urlParts);
console.log(window.location.hostname);
console.log(
url.format({
protocol: urlParts.protocol,
auth: urlParts.auth,
hostname: (urlParts.hostname === '0.0.0.0') ? window.location.hostname : urlParts.hostname,
port: urlParts.port
})
); |
|
Oh seems to be Lync messing up the copy paste... Using I still think |
It parses valid URLs correctly, so as far as we should be concerned it behaves as intended. |
can we get port to be like this?
|
@SimenB would the approach you guys are discussing work when connecting to your dev machine from other devices? To accomplish that when I need to change the port I've been using this hack: <script type="text/javascript">
var scriptElem = document.createElement('script');
scriptElem.type = 'text/javascript';
scriptElem.src = new RegExp('https?://[^:/]+').exec(window.location.href)[0] + ':9090/assets/client.bundle.js';
document.head.appendChild(scriptElem);
</script> |
Yeah, connecting from other machines works fine, as long as they're on the same LAN. Might work independently of that, but we haven't tested it |
@SimenB What do your script tags look like? I've been curious myself if there's a better way |
I use Relevant part of template: <body>
<div id="container"></div>
{{#each htmlWebpackPlugin.files.chunks}}
<script src="{{this.entry}}"></script>
{{/each}}
</body> My entry for webpack can be seen in a comment above |
Oh, are you using Meteor? |
No, it's Backbone app, but the templates are using Handlebars, so I kept going with that for html-webpack-plugin (as I really dislike blueimp). Next version of the plugin will support lodash templates though, so we'll probably switch to that. |
I see. But now you're just using |
Related #46, #220, (kind of) #239
This PR allows you to use
'webpack-dev-server/client?http://mydomain/mysocket.io/'
(domain is optional, just as path is). I.e. being able to change thesocket.io
path too and not just the domain. If there is no path you get the current behavior.url.parse
parseshttp://example.com
as having path/
(so we must consider it no path), but that's not really a problem and preferable to avoid breaking existing configs.If anyone wants to try it:
"webpack-dev-server": "git://github.com/syranide/webpack-dev-server#socketiopath_npm"
cc @sokra