-
-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(css): rewrite absolute URLs with base path in dev mode #14622
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
Open
aprici7y
wants to merge
5
commits into
withastro:main
Choose a base branch
from
aprici7y:fix/css-base-path-dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+400
−1
Conversation
This file contains hidden or 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
Fixes CSS url() references to public assets returning 404 in dev mode when base path is configured. Applies URL rewriting after preprocessCSS() using Vite's cssUrlRE regex pattern. Closes withastro#14585
🦋 Changeset detectedLatest commit: 9eb95ff The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #14622 will not alter performanceComparing Summary
Footnotes |
Contributor
|
looks good overall |
Contributor
Author
|
fixed the linting error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
url()references to public assets returning 404 in dev mode whenbasepath is configuredrewriteCssUrls()function inpackages/astro/src/core/compile/style.tsthat applies URL rewriting afterpreprocessCSS()cssUrlREregex pattern from vite/packages/vite/src/node/plugins/css.ts/fonts/font.woffto/my-base/fonts/font.woffin dev mode./), external URLs (https://), data URIs, and protocol-relative URLs (//)Root cause: Vite's
preprocessCSS()API explicitly does not resolve URLs (docs). During build, Vite's CSS plugin handles URL rewriting, butin dev mode Astro calls
preprocessCSS()directly, bypassing the URL rewriting step.Closes #14585
Testing
25 unit tests added in
packages/astro/test/units/compile/css-base-path.test.jscovering:Manual testing: