-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add default port as 8080 in options.js to match webpack-dev-server.js #1795
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
Comments
We already use |
What is problem, how you run |
I just run If you would like, I can put together a minimal reproduction that shows the issue. |
Please provide, default port is 8080, so something wrong in you configuration |
Also since |
Ah okay I think this is actually related to my use of https://github.com/gajus/write-file-webpack-plugin I use this plugin to force So, to revise the above issue, leaving out the Snippets from the bundle: When setting
When leaving
If this is just an expected assumption made by |
Now that I think about it though, taking the minimalist approach to configuration, branching on where I load |
You can replace |
hm, maybe be we forget adding port in some cases 😕 Yes, need reproducible test repo |
Alright, got together a minimal reproduction of the issue (with all the changes you suggested). Steps to reproduce:
One more thing to note however, is that I found another error, this time even when using Maybe this indicates that the files generated by |
I didn't test it, but from what you said, I suspect createDomain is not adding the port correctly, since |
Don't use Anyway if you find better solution PR welcome. We investigate this in future. |
I think |
Just added some console logging to
Here are the results: When
When
Looks like the first call to
This resolves the error, and I can successfully use Regarding your other comment about the CORS problem: "Don't use file, it is normal what you get CORS problem.", I'm not sure what you mean. I don't create any URLs with |
Let's fix problem with default port, PR welcome 👍 |
I'll be honest, I'm stumbling around trying to figure out where the change should be and why, but I don't know how to make it so that it doesn't break other things. So far, it looks like we shouldn't change Maybe someone who has more experience with the source could take a look... sorry I can't be of more help, first time really looking at |
One more thing I just noticed from reading the source, I think the change should probably be to the |
Ah yes looks like the change would be to here:
The problem with just adding the default port 8080 as a fallback here would be that it wouldn't use the port finder result (from |
Yep, it should be easy |
So It seems there would be two ways around this:
I'll try and poke around with the second option and do a PR if I can get something to work. |
@SirUppyPancakes came here to say that we were having of same problem. switched to https://www.npmjs.com/package/webpack-plugin-serve and haven't had issue since. it support |
Thanks for the link! @thesaltygerman That definitely looks like a decent alternative. I think once I get a PR in (if I can manage to find a nice place to add in the default port value), |
I think it is bug:
|
So I've nailed down the exact problem now, just need to come up with a way to minimally change the code to fix it... When the server is created in
it passes This all happens before we ever call So we end up with a coupling/dependency problem:
So we can't easily move the To me, it seems the only good solution to this would be to decouple all of the code that deals with the I don't think I am confident enough to do a pull request for this, as this will require a lot of restructuring of the code, and I am not familiar enough to do that confidently. |
Not sure it is solve the problem |
In v3.8.2, when using with program style, you also need to specify the new WebpackDevServer(compiler, {
port: 8080, // do not ignore this
}).listen(8080, 'localhost', function(err) {
console.log("[webpack-dev-server]", "http://localhost:8080/webpack-dev-server/index.html");
}); |
Hii, @alexander-akait @SirUppyPancakes, Is this issue still exists? |
I think it is fixed, but need test |
Close in favor #3351, we will fix it in near future, also now we have |
Code
The minimal changes to
webpack.config.js
to introduce HMR are:Expected Behavior
The
port
option should default to8080
(just like the server does).Actual Behavior
The
port
option does not have a default, which results in the generated code trying to contactwebpack-dev-server
at the default port (for URLs) of80
.Relevant
webpack-dev-server
codeIn
bin/webpack-dev-server.js
In
bin/options.js
(missing adefault
key)For Bugs; How can we reproduce the behavior?
Simply remove the
port
option above from a simplewebpack-dev-server
example project. There will be console errors on the loaded page, and if you check the generated bundle code, you'll find that it tries to contactwebpack-dev-server
athttp://localhost
instead ofhttp://localhost:8080
For Features; What is the motivation and/or use-case for the feature?
Having less required options makes
webpack
much more approachable to beginners looking to "just make it work".The text was updated successfully, but these errors were encountered: