Skip to content
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

🐛 BUG: The local font files referred via css/scss isn't processed well in built css. #2276

Closed
vipindigiqt opened this issue Dec 26, 2021 · 5 comments

Comments

@vipindigiqt
Copy link

What version of astro are you using?

0.21.12

What package manager are you using?

yarn

What operating system are you using?

Linux

Describe the Bug

I'm trying to reference my local font files which are in public/assets/fonts/ (.woff, .woff2) through scss and I'm using /assets/fonts.. to refer them.

Its all fine on local server, but breaks on CSS build. the relative font url is not correct in css.

Link to Minimal Reproducible Example

https://codesandbox.io/s/cool-jepsen-s83m7?file=/src/pages/index.astro

@vipindigiqt vipindigiqt changed the title 🐛 BUG: 🐛 BUG: The local font files referred via css/scss isn't processed well in built css. Dec 26, 2021
@vipindigiqt
Copy link
Author

Update: I tried Fontsource as well but It's not working as well.

Still getting this weird (to me) asset ref in built css:

@font-face{font-family:"Inter";font-style:normal;font-display:swap;font-weight:400;src:url(__VITE_ASSET__444c3024__) format("woff2"),url(__VITE_ASSET__054f12d0__) format("woff");

@ahsath
Copy link

ahsath commented Dec 28, 2021

x2

@jonathantneal
Copy link
Contributor

jonathantneal commented Jan 4, 2022

I believe this was fixed in a later version of Astro than 0.21.12. I’m unable to reproduce this. I tested locally using 0.22.4 using both astro dev and astro build.

@retronav
Copy link
Contributor

@ahsath @vipindigiqt Not sure if you still have the issue, but I made this script to replace the VITE_ASSET references with the correct file names, which you can run post-build.

@tony-sull
Copy link
Contributor

Looks like this may have been fixed in a later version of Astro as @jonathantneal mentioned above

The VITE_ASSET issue above is tracked by #2146 and is currently blocked by an upstream issue and PR in Vite 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants