-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): Allow forcing publicPath on dev mode too (for SPA and PWA …
…only) #4962
- Loading branch information
1 parent
1fb3c59
commit 256e8b8
Showing
4 changed files
with
42 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
256e8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, but this commit forced the
<base>
tag usepublicPath
as href, which will caused a'replaceState'
error when<base>
tag'shref
is different from app'shost
and enabledhistory
invueRouter
. This seems to be a bug or missing feature invue-router
. What I expecting is there is no<base>
tag in the<header>
or the<base>
tag's href is'/'
. I can't upgrade to v1.0.6 for it will break the compromise methods i'm using now.You can easily got the router error when assign publicPath as your local ip such as
192.168.0.1:5000
and visit it fromlocalhost:5000
or127.0.0.1:5000
. In addtion, visit from192.168.0.1:5000
is fine. Unfortunately, i can't visitpublic.example.com
to use the app.256e8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you assigning the publicPath to a full URL? It should only contain the path, not the full URL...
256e8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally it should, but unfortunately there are some case the publicPath will dynamically change when building and deploying. In my case, I'm using a script like
CDN_PATH=http://192.168.0.1:5000/***/ quasar build
when building(the***
part will change in each building, normally is a timestamp like string), and theCDN_PATH
variable is using aspublicPath
.Using publicPath as
<base>
is all OK except it will throw areplaceState
error when enabledhistory
andscrollBehavior
invue-router
as shown in ISSUE 2593, which seems has no solution.Is there anyway to avoid this ? Pardon my poor english.
256e8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused about another thing. If you look closely, this commit is just a refactoring while maintaining the same logic (the outcome is the same, just the variables have been "moved" a little). So not sure why commenting on this particular commit actually.
Also, I'd like to understand if you are indeed using publicPath correctly. Are you using it to supply the built js and css files, or for the statics (images, etc)? Cause if it's for the latter, then you're not doing it right...
Also note that Vue Router has its own base (from which "origin" is extracted away). I just have the feeling that you are trying to solve a scenario by wrongly hacking on the publicPath when there should be another way to do it correctly.
Any barebones repo to (reproduce this with) available that I can take a look at? And some basic instructions on how to set it up and run it (as I'm not very familiar with Laravel).
256e8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your replies, I've create a repo replaceState-error-in-vue-router which can reproduce the
replaceState
error. In themaster
branch, I'm using@quasar/app 1.0.6
, enabledhistory
invueRouteMode
andscrollBehavior
inroutes/index.js
, after building and running thequasar serve
, openlocalhost:4000
, you'll see thereplaceState
bug. In theno-bug
branch, I'm using@quasar/app 1.0.5
, enabledhistory
andscrollBehavior
inroutes/index.js
, there is no error.Basically it's a
vue-router
bug, and the unusual deployment, unfortunately, I can't change either of them256e8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because js and image resources are hosted on a third-party cdn and are not in the same domain as index.html, I have the same needs.
Can the
base
tag restriction be removed?256e8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fxjs I have the same problem (serving assets from my CDN) and we are discussing it in #4687 (comment) . (Just cross-referencing)