-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Resolving Assets in CSS via url() #9633
Comments
Seems like it's because Vite uses
I'm not really sure of a way to fix this. Might need to sit on it for a while. Maybe there's a way for us to partially fix this for most cases by using Vite's |
Current workaround is:
|
It doesn't seem like it. For my case, I chose to stuff all images into a subdirectory of the It also seems that this issue is gaining traction, so they might try to set some time into it. But I'd still give it some more time, as from the looks of it, the process(es) of creating the resolved images is triggered a decent bit before everything else (which @bluwy mentioned). I'm going to assume that this might be addressed further in early/mid v5 🤞🏻. |
Thank you for your response. I updated my comment and added a workaround. However, there's now an issue with PHPStorm/WebStorm not recognizing aliases within the |
Running into this issue as well. |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Doesn't seem to apply.
Describe the Bug
When trying to use images in CSS, I can't get the image to load with paths like
@images/
,../images/
or/src/images/
. I'm limited to using images in thepublic/
directory where the images aren't processed and optimized like into thewebp
format. Images will be not found (404) in my console in and/or development/production:Note: I could just be me not understanding the proper implementation, but from the Discord support thread, it seems I'm not the only one confused.
What's the expected result?
It should be a straightforward way to resolve images and use them in CSS. Like simply putting:
or other ways like using
define:vars
:With these, then the images should automatically be processed and URLs resolved and replaced so they show up as an optimized image in both production and development.
Link to Minimal Reproducible Example
https://stackblitz.com/~/github.com/KingPr0o7/sandbox
Participation
The text was updated successfully, but these errors were encountered: