Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Support for static image imports #24993
Support for static image imports #24993
Changes from 33 commits
996dc7f
6dea6a2
21400ba
c6ad7c5
b5f2c12
bc5c64a
aa9e4fd
9b4c513
fdd27c4
7c138de
ccefcb2
acd4ae3
5a8ce4c
29892e3
108aed9
b6a199a
d4149d2
809d86e
2e183bd
85d3d06
f937233
9659f46
c65e416
357523a
0ed6844
6b8f5fb
a23b5f0
6cb22b8
88d28f2
cb63fbb
8d4938e
09b0799
4e387d7
9932cd8
6a94a6d
cfe7b38
0956c0d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Can't we use https://www.npmjs.com/package/file-type instead, this ensures the content is always the correct type.
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.
I would prefer to put the meta information into a separate export, so the default export stays only the URL for backward-compat reasons. Currently enabling this feature, breaks all existing image imports as it returns an object instead of an url now.
You would use it like that:
@timneutkens What do you think?
The import might be easy to get wrong... A lint rule could help with that.
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.
Image imports are not supported in Next.js currently, so that should be fine, potentially we can do the same as the css imports detection to disable the loader if there's customization that would break? 🤔
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.
Will this work?
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.
Without this casting, a lot of references to
src
further down the file have problems because they only want a string. Since as of this line, we knowsrc
is a string no matter what, I think the cast is probably ok.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.