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 <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
|
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 |
| inlineConfig: InlineConfig | ||
| root: string | ||
| base: string | ||
| rawBase: string |
There was a problem hiding this comment.
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/assetsfor testing and reused that code (already available with/foo/as base). There is already some duplicated code betweenrelative-baseandruntime-base, which probably could be combined altogether (?).Not all tests are successful yet:
pnpm run test-build assetsleads 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 assetsAssertionError: 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 devnorpnpm run build/preview).What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).