Closed hrishikesh-k closed 2 months ago
Here's a similar setup with SvelteKit: https://stackblitz.com/edit/github-ggpyjq-wsd36g?file=src%2Froutes%2F%2Bpage.svelte, where I'm using import aliases and Vite is able to load the file and embed it as base64 in the generated CSS.
Generating base64 is not the end-goal. The end-goal is to be able to use import aliases in CSS url()
functions. However that doesn't seem to work with Astro for some reason.
Duplicate of https://github.com/withastro/astro/issues/9633
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
If you try to import a font file (it might even happen with images, I just didn't test it) in the following manner:
it gets correctly processed by Vite and end up being added to the bundle. However, if you try to replace that import with an import alias, it doesn't work. When running
astro build
, Vite throws a warning:What's the expected result?
The import alias should work even there. It works as expected in SvelteKit which also uses Vite. Since Vite is able to load and process the file correctly (as indicated when you use relative URLs), it should be possible to use import alias as well.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ggpyjq?file=src%2Fpages%2Findex.astro
Participation