-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
feat: base without trailing slash #10723
feat: base without trailing slash #10723
Conversation
playground/assets/__tests__/without-trailing-slash/without-trailing-slash-assets.spec.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Ben McCann <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
We have discussed this in the last team meeting and agree that An implementation detail we want to make sure is that the |
@BenediktAllendorf I finally figured out that most of the failing tests were not because of any code changes, but the test themselves. Once you put the test in a sub-directory they no longer pass. I changed the test setup to put the new tests alongside the old tests |
Hmm, the way I setup the tests seemed to cause them to collide with each other. I just removed them and instead edited the base path on the existing tests to not have a trailing slash. Since there are so many other tests that have a base path with trailing slash we should still have good coverage |
@@ -323,6 +323,7 @@ export type ResolvedConfig = Readonly< | |||
inlineConfig: InlineConfig | |||
root: string | |||
base: string | |||
rawBase: string |
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.
Let's mark rawBase
as internal. I would prefer to have this option as you did here, but there was a push in the last team meeting to go there only when there is a real use case out of the Vite core middleware.
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
vite-ecosystem-ci looks the same as before this PR, except for Svelte @benmccann but I expect that you are aware or ok with this to move forward. |
Thanks for the review @patak-dev ! I marked the new field as internal. The svelte failure is unrelated and looks to be a network flake during CI setup, so I'm not worried about that one |
Hi is this released? |
@rssfrncs yes, in Vite v4+ |
Description
Allows setting a base without trailing slash. Closes #9236. Closes #8770. Closes #8772
I assumed, that
base = "/foo/"
andbase = "/foo"
should work equally for all sub-urls and only differ in the behavior when calling only the base (e.g., "localhost/foo" vs "localhost/foo/"). This means, that even without the trailing slash, all generated paths look likelocalhost/foo/css/...
and not likelocalhost/foocss/...
.Additional context
I used
playground/assets
for testing and reused that code (already available with/foo/
as base). There is already some duplicated code betweenrelative-base
andruntime-base
, which probably could be combined altogether (?).Not all tests are successful yet:
pnpm run test-build assets
leads toAssertionError: expected '/non-existent' to include '/foo/non-existent'
. The problem is, that the path is not available and therefore, will be resolved at runtime - but this basically means,URL("non-existent", "/foo")
will be called (instead ofURL("non-existent", "/foo/")
as it would do with a trailing-slash-base. I'm not sure, what the expected/desired behavior here would be?pnpm run test-serve assets
AssertionError: expected 'url("http://localhost:5173/foo/@fs/ho…' to include '/foo/nested/asset.png'
andAssertionError: expected 'http://localhost:5173/foo/@fs/home/be…' to include '/foo/nested/asset.png'
are both related to "@fs"-importsAssertionError: expected 'url("http://localhost:5173/nested/ass…' to include '/foo/nested/asset.png'
reveals a problem with inline-CSS.For
test-serve
, I'm not sure where those problems occur (and why I don't see that neither withpnpm run dev
norpnpm run build/preview
).What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).