-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Image loaders for component packs #4388
Comments
Agreed! This is a very typical pattern for using SVG files in React components. It looks like the SVGR esbuild plugin could be helpful here: https://github.com/kazijawad/esbuild-plugin-svgr |
Yep, was thinking esbuild-plugin-svgr for SVG and there are a few different options for png/jpg/etc., possibly one that handles responsive images (see #4358). Will need to make sure that any other assets that are generated are included in the pack - likely here but haven't looked that closely yet. Related #4395. |
Disclaimer: I'm still new to the uesio codebase so possibly I'm misunderstanding how "pack" works In reviewing the current code base, it appears the approach is to invoke esbuild natively in go using the esbuild apis. This works well, however when considering additional loaders, most do not have a go implementation so they can't be used directly. There are a few different options I believe:
I don't think any of these are ideal but thinking that option 1 may be the most straightforward and cause the least amount of headaches down the road. It would provide full access to the entire esbuild ecosystem. For some background:
Thoughts on how to best approach basedd on current need for image loaders and future flexibility? Other options to consider? Edit Another thing to consider here is potentially needing to allow users to modify the build config to support other loaders, etc. The stock implementation can support common file types but there may be needs for specifying esbuild config, adding loaders, etc. from users at some point. There is something to be said for not allowing this but also for allowing. Currently, I don't see a way where/how this would be possible in the current code and while not directly related to image loading for this issue specifically, any change in approach to calling esbuild likely should keep this in mind. |
When developing a component, a common approach to using images is:
Currently, when attempting to import images (e.g., svg, png, etc.), the following error is encountered during
pack
:While it is possible to add a
File
and use apis (e.g.,api.file.getURLFromFullName
) to obtain the corresponding URL, using images natively is a common pattern in React and building a pack should support image file loaders.The text was updated successfully, but these errors were encountered: