-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Assets use file-loader instead of url-loader #7061
Conversation
Deploy preview for using-postcss-sass failed. Built with commit 742b913 https://app.netlify.com/sites/using-postcss-sass/deploys/5b698275b13fb115bd788d68 |
Deploy preview for gatsbygram ready! Built with commit 742b913 |
Deploy preview for gatsbygram ready! Built with commit f0f24fa |
Deploy preview for using-drupal ready! Built with commit 742b913 |
Deploy preview for gatsbyjs failed. Built with commit 742b913 https://app.netlify.com/sites/gatsbyjs/deploys/5b698274b13fb115bd788d5c |
Thanks for jumping on this! We don't actually want to eliminate the use of |
How about something like this: /**
* Loads audio and video and inlines them via a data URI if they are below
* the size threshold
*/
rules.audioVideo = () => {
return {
use: [loaders.url()],
test: /\.(mp4|webm|wav|mp3|m4a|aac|oga|flac)$/,
}
}
/**
* Loads assets without inlining
*/
rules.miscAssets = () => {
return {
use: [loaders.file()],
test: /\.(pdf)$/,
}
} |
Looks great! If @jquense is around, I'm sure he has thoughts too as he wrote this code. |
Gatsby v1 loaded font files also with file-loader (link), whereas v2 loads it with the url-loader. Some additional insight would be nice 👍 This also reminds of this issue: facebook/create-react-app#3722 Like, it would be nice to let the user decide what he wants import { url } from './image.png'; // file-loader
import image from './image.png'; // url-loader But thats not solved yet :) |
We think GraphQL is better for letting people specify transforms :-) I think fonts are fine leaving w/ url-loader. We have url-loader setup to only inline assets < 10kb. If a font file is < 10kb then it's probably better to inline it to speed rendering. PDFs are different as you never want it inlined as you really only want a link so you can offer it to someone to download if they'd like so inlining is almost always a waste. |
Holy buckets, @zauni — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Thanks! |
Thank you very much for your fast responses! |
Thank you very much for fixing the problem! |
* Assets use file-loader instead of url-loader Fixes gatsbyjs#6963 * Just pdf files use file-loader
Fixes #6963