-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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]: font files are not moved to _assets
directory on build
#1153
Comments
Related: #185 (comment) |
Using the local font from npm is one of the methods described in MUI's docs: https://mui.com/components/typography/#install-with-npm I would expect this to work out of the box with Remix. |
I found the following workaround on the Remix Discord (credit goes to @kiliman): https://discord.com/channels/770287896669978684/940920958540197889/941007998388690985 For those who don't want to / can't follow the Discord link, add this to your
|
If you are using PrimeIcons with PrimeReact then the script is... Unix:
Windows:
|
Copying font files manually does not work with the latest version (1.6.4) anymore. Font file references are now cache busted. Is there a way to disable cache busting for css or make remix copy the font files? |
looking into this a bit, looks like esbuild doesn't copy imports/urls from |
edit: made an example repo - https://github.com/mcansh/playground-1658515042024/tree/main i did manage to get this working using // ./postcss.config.js
const path = require("node:path");
const fse = require("fs-extra");
module.exports = {
plugins: {
"postcss-import": {},
"postcss-url": {
url: (asset) => {
let { absolutePath } = asset;
let basename = path.basename(absolutePath);
let outDir = path.join(
__dirname,
"public",
"build",
"_assets",
"fonts"
);
let destpath = path.join(outDir, basename);
if (!fse.pathExistsSync(destpath)) {
fse.copySync(absolutePath, destpath);
}
return "/" + path.join("build", "_assets", "fonts", basename);
},
},
},
}; // ./styles/index.css
@import "@fontsource/aguafina-script/index.css"; using "scripts": {
"dev:css": "postcss ./styles/index.css --output ./app/styles/index.css --watch",
"dev:remix": "remix dev",
"dev": "run-p dev:*"
} // ./app/routes/root.jsx
import fontStyleUrl from './styles/index.css'; |
So this method works when running My fix for this was to add a
if you use
UPDATE:
|
I think this should be handled by the framework and not by developers using the remix.
Otherwise I see
I think that esbuild has some problem here or it is used on way which doesn't allow to parse css properly. |
definitely, i took a quick look at this a bit ago - never opened an issue on esbuild yet, but looks like if you use a |
looks like this is what we need to do: evanw/esbuild#1757 (comment) looking into it :) |
We're actually rebuilding the Fontsource website with Remix so this is huge. Thank you so much for giving up your time for this @mcansh and @KingSora! |
🤖 Hello there, We just published version Thanks! |
Fixed in 1.7.3, thank you @KingSora 🎉 |
Hi Friends !!! // in your root project:
// in your package.json file allocated in your root project:
// in your css file to load in your route:
// in your css file to load in your route:
Its worked for me !! |
@sergioarieljuarez if 1.7.3 didn't work for you here, please open a new issue and provide a public repository reproducing the problem 🙏 |
@universse please ask support questions in the Discussions tab. |
What version of Remix are you using?
1.1.1
What version of Node are you using? Minimum supported version is 14.
14.18.1
Steps to Reproduce
Example on stackblitz.com
yarn create remix
to create a new remix project.yarn add @fontsource/aguafina-script
root.tsx
: (source)yarn dev
and visit the page in you browser.Expected Behavior
Font files (*.woff or *.woff2) from the fontsource package are copied to the
_assets
folder. Also, the compiled version of the fontsource css points to these font files.Actual Behavior
Font files are not copied to the
_assets
folder. Browser receives HTTP 404 when trying to load the font.The text was updated successfully, but these errors were encountered: