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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 BUG: Build/bundle assets not working #2453
Comments
@schlichtanders I had the same problem and I didn't find the solution, finally I use astro-icon lib, but I have doubt what is the way for including CSS libraries in astro project? |
@nicobytes thank you for mentioning astro-icon. Even for icons astro-icon is not suitable for my requirements. But anyway, this ticket Minimal Working Example is not about icons but about fonts (google fonts). Hence astro-icon cannot help at all. To the best of my understanding, this is just a normal bug and needs fixing. @matthewp can you take a look? |
Verified with |
I'm going to take a quick look and see what's going on. |
This works well without the extension (fontsource falls back to the standard weight - 400). |
I looked into this one and this is what's going on:
I was able to patch some changes locally to get the example app working. However it takes a change to Vite's API in order to expose the internal private state of the asset plugin. I'll reach out to the Vite team about exposing this so that we can use it. After that it will be a fairly simple fix. |
This is the upstream issue which enable us fixing this: vitejs/vite#6625 |
Thanks for filing this issue, and the investigation above! Closing as a duplicate of #2146 as the primary for this issue |
What version of
astro
are you using?0.22.17
What package manager are you using?
npm
What operating system are you using?
Linux
Describe the Bug
While this merged pullrequest #1786 created some internal logic which copies assets, it unfortunately doesn't work.
The reason is mere file naming.
url(some/relative/path/to/myfile)
get translated to hashedurl(__VITE_ASSET_12314)
.__VITE_ASSET_12314
but gets a combination of original name and hash, something likemyfile_XH14K
.This makes it currently impossible to work with npm assets. It is as severe, that astro's internal logic will interfere (concretely overwrite it) other manual approaches like using
postcss-url
to accomplish the job of copying npm assets. That was quite surprising behaviour, seeing postcss-url copying files, which then get deleted again and renamed wrongly by some black astro magic.TODO:
The MRE shows the use of fontsource. While
npm run dev
will show it correctly, runningnpm run build && npm run preview
cannot find the font file as supposed to.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-gw1vrc-uazpyq?file=src/pages/index.astro
The text was updated successfully, but these errors were encountered: