-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Allow custom publicPath to be set alongside baseUrl #2525
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
Isn't Have you actually tried of changing the publicPath would solve your problem (by temporarily commenting out the codes raising the error in /node_modules/)? The error is raised because we need to match the public path and some. Other paths we are setting, Changing it like you want to should most likely break the build. |
Ah, shoot, I tried changing |
I stand corrected! It really seems like that should work, however, for some reason After that, subsequent requests are still made to my app server ( I've tried combining That said, I did try commenting out the validation code in So this does not work:
But this does:
It's also worth noting that it isn't just the |
(see below for a reproduction code) Same issue here... Modifying The problem is that the /******/ // script path function
/******/ function jsonpScriptSrc(chunkId) {
/******/ return __webpack_require__.p + "" + ({"vendors.spgrid":"vendors.spgrid","spgrid":"spgrid"}[chunkId]||chunkId) + ".js"
/******/ } It uses /******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/"; Because I'm using a different server (https://myserver/some/path/), it tries to load the resource from this server instead of the dev server:
There is a match that is done by // {"vendors.spgrid":"vendors.spgrid","spgrid":"spgrid"}
{
"vendors.spgrid":"vendors.spgrid",
"spgrid":"spgrid"
} I'm not sure where it could be defined, but maybe it could be replaced by the below (instead of using {
"vendors.spgrid":"https://localhost:18827/vendors.spgrid",
"spgrid":"https://localhost:18827/spgrid"
} Reproduction
In the console of CodePen you'll see:
Instead of:
It's because And the simple config: module.exports = {
devServer:{
https:true,
port:2525,
host:'localhost',
public:'localhost:2525'
}
} |
Same need/problem here :) |
I am having this issue too. Using .NET Core to proxy the vue cli server for local dev. I think another option would be to allow a relative path for the HMR, so it would work no matter which URL. Alas, putting '/' does not work. |
We have the same need for development environment |
@ralphchristianeclipse Agreed that this seems odd, but modifying
|
I just ran into this same issue. I'm running Vue CLI inside a Vagrant box with SSL configured. Setting public and publicPath to something like https://dev.domain.com:8080 gets everything working except for hot-update.json which ignores the port and makes the request to https://dev.domain.com. Adding baseUrl solved that and everything is working correctly but baseUrl triggers the warning that it is deprecated and to use publicPath (which again, I already am). Any ideas of another way to resolve this? |
I was able to solve with both baseUrl and publicPath. I had problems with 'hot.update.json' files, for hot-reload: without
|
With |
Happy to report this is no longer an issue! I just tested this on v4.0, but it looks like it was actually fixed somewhere even before that. The important difference is that For reference, here's a working configuration for those who want to force the browser to load the bundle and HMR updates from
|
I done it by. |
What problem does this feature solve?
Right now any attempt to set
publicPath
prevents the bundle from compiling with the following error:I understand why that validation is there, as it prevents accidental misconfiguration when users aren't aware of the
baseUrl
option. That said, there should be some way to bypass this error (or make it a warning).My bundle gets served from my webapp which is running on a different localhost port (let's say 4000). As such, HMR attempts to load from
http://localhost:4000/xxx
instead ofhttp://localhost:8080/xxx
. I can't put thehttp://localhost:8080/
in thebaseUrl
because it simply tacks that onto itself (http://localhost:8080/http://localhost:8080/
).I really just need to override the
publicPath
for webpack, but keep thebaseUrl
exactly as it is. I've tried a thousand different things but there doesn't seem to be any other way around this.What does the proposed API look like?
Either make it a warning, or add some kind of flag that says "hey, I know about baseUrl and I've set it, I just also want to set publicPath too."
Frankly, if both
baseUrl
andpublicPath
are set, it can probably be assumed that it's intentional. Maybe only display the error ifpublicPath
is set withoutbaseUrl
.The text was updated successfully, but these errors were encountered: