-
Notifications
You must be signed in to change notification settings - Fork 137
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
Add static asset loader for fonts and images. #1323
base: main
Are you sure you want to change the base?
Conversation
2 cents for 1 and 2, just IMO: |
ember-svg-jar and ember-responsive-image would need to provide either webpack plugins are unplugins -- which still need webpack / etc configuration -- they cannot do anything automatically -- but they could document how to do this configuration for both ember-auto-import and embroider. So, we should only do fonts? |
maybe we could do images but e.g. in a way that is easily "swappable" with ember-svg-jar or/and ember-responsive-image ? |
that would be ideal for config-resistant folks, I think -- but I'm not sure how it'd work, technically |
Next step here is to keep exploring / pushing-forward this kind of RFC: emberjs/rfcs#763 |
FWIW, the next-gen v2 version of ember-responsive-image will ship with custom webpack loaders, but it will also suggest users to add a custom module rule like this that will only activate its loaders when a certain query param is in the module specifier, so users can opt into the responsive-way of importing images while still keeping any other image imports the same as they are (the "virtual" module that these loaders emit are vastly different and incompatible, so using responsive loader for all image imports would break things). So I think the default for imports of any static assets should be what the RFC suggests, to return the URL of that asset. If people want more, they can opt into that by adding custom loaders. |
test: /\.(jpg|jpeg|png|woff|woff2|eot|ttf|svg)$/, | ||
use: [ | ||
{ | ||
loader: 'url-loader', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is deprecated and replaced by asset
loader for webpack 5!
I think there should at least be some mention of this in the readme. Maybe a link to some standard configuration like fonts/images? Personally, I am not familiar with Webpack (but I should be!). Using Ember, I expect a "batteries included" experience that I've had in the past. Limiting boilerplate, etc. Today, I was using Tailwind to try something out, and this code broke my build: <div class="bg-[url('/sample.png')]"></div> Not knowing much about Webpack, I was surprised to see it even trying to do anything with
But, it finally made sense when I realized that I was importing CSS directly inside app.js! Okay, something I've done in React projects, like Gatbsy, where there's configuration that tells Webpack how to handle images. I imagine that that asset RFC will tackle things like this. But maybe just adding a final step in the readme will prevent some confusion. |
People don't like configuring webpack (this is known, across all ecosystems, not just ember).
Today, we support importing CSS in JS, like :
for example, which mostly does the right thing, and adds the CSS file to your module graph (doesn't make the CSS available in JS for use class-use in JS, etc)
However, this file also has fonts in it.
ember-auto-import and embroider don't currently have a font loader.
In this PR, I've added a config while working with @spuxx1701, which I believe is "just from around the internet".
It brings up some questions:
<use>