-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
CSS imported by explicit import with ?url suffix do not have resolved its dependencies #7842
Comments
Thank you for your reply. My current working hack is to put fonts to public/assets/fonts/.... |
I am having the same issues. My company UI library is exporting something like:
I would expect vite to resolve it to (on serve)
And on build make sure to copy this asset. Just like @keeema I tried using assetsInclude but that doesn't seem to do the work. Did anyone else managed to solve this issue? |
For what it's worth, I'm running into a similar issue. I'm in a monorepo, declaring a React component which renders a <style> tag with the CSS font declarations in a common components package. eg: import React from 'react';
import NotoSansRegular from './NotoSans-Regular.ttf';
const Styles = () => (
<style>
{`
@font-face {
font-family: "Noto Sans";
font-style: normal;
font-weight: 400;
src: local('Noto Sans'), local('NotoSans'),
url(${NotoSansRegular}) format('ttf'),
url(${NotoSansRegular}) format('woff'),
url(${NotoSansRegular}) format('woff2');
}
`}
</style>
);
export default Styles; and my consuming application within the monorepo (which I'm converting from Webpack to Vite) renders that via another component in its React tree. In build and preview mode this works just fine, the files are put into the asset folder I specify, they download and the elements that use them, display correctly. When using the dev server, the urls end up being the full url such as:
That seems correct, and putting that URL in the browser attempts to download the font as you would expect. However, the network tab shows it as
And thus the browser does not use the font. |
Same issue here. No loader is configured for ".woff" files: node_modules/@fontsource/roboto/files/roboto-all-300-normal.woff |
Also running into this. |
I also have this problem. |
Describe the bug
I need to import files with explicit import and use their url in react useEffect. I use it to dynamically bind themes CSS according to switch.
Unfortunately, CSS imports with suffix
?url
do not have resolved its dependencies, so if they contains fonts defined byurl(somePath)
then suchfonts from somePath are not included in assets in dist.There is not fully reproducing code in stackblitz because I can't upload fonts... but there is an example code.
Reproduction
https://stackblitz.com/edit/bad-imports-css-url
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: