Conversation
| const parsed = parseUrl(url) | ||
| const path = parsed.pathname || '/' | ||
|
|
||
| if (path.startsWith(root)) { |
There was a problem hiding this comment.
I think we should check for path.startsWith(root + base), then replace to req.url = url.replace(root + base, '/').
If we have root as /home/xxx/, and base equals to /home/, the current implementation will fail, no?
There was a problem hiding this comment.
root + base = /home/xxx/home/ ?
In my test case, path will be <root>/[relative path from root]
There was a problem hiding this comment.
Oh, gotcha, you are actually trying to fix the other way around.
I thought the bug was that /home/xxx/home/path was converted into /xxx/home/path, that seems to be an issue currently.
I don't understand your case, I think that absolute paths will be covered by the rule I proposed. And paths relative to the project root will also work.
The only case that won't be covered is is when you are trying to have an absolute path out of root, but in that case Vite will use /@fs/, no?
There was a problem hiding this comment.
I update the desc.
If set the base URL to root on Linux and use vue plugin, vue plugin will import css by absolute path. And vite will replace base to
/, and absolute path startWithbase pathwill got a error.
There was a problem hiding this comment.
@patak-dev the case is
config with
{
base: "/home/"
}- had absolute path
/home/xxx - root is
/home/xxx/project
so the request must be /home/xxx/project/assets (because the request will call by the vue plugin)
and then replace root to be /assets
There was a problem hiding this comment.
I thought the bug was that /home/xxx/home/path was converted into /xxx/home/path, that seems to be an issue currently.
Is there a way to reproduce this possible? I've been thinking about it for a long time and can't figure it out. 😂
Description
fix: vitejs/vite-plugin-vue#25
Additional context
If set the base URL to root on Linux and use vue plugin, vue plugin will import css by absolute path. And vite will replace base to
/, and absolute path startWithbase pathwill got a error.this PR analy
req.url(absolute path)includerootwill replace it to emtry strings and then it will be a<root>/[relative path]What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes vitejs/vite#123).