Replies: 2 comments 2 replies
-
This is a valid concern |
Beta Was this translation helpful? Give feedback.
0 replies
-
Why is this issue closed is there any solution yet? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Summary
Make @astrojs/image compatible with front end libraries (React, vue...). I think this is in the spirit of being able to use astro with what ever framework you want.
Background & Motivation
Currently, if you have any images inside your React/vue... components they will be unoptimized, even if those components are static. Solutions I have found around this problem which are all hacky:
Pass @astrojs/image component as child as per docs. The moment you have multiple images or anything slightly complex this becomes a nightmare
Use an external image hosting solution or use a custom serverless function to provide optimized images. This comes with its own downsides obviously.
Build your own image optimizer & image component. This is ultimately what I have done it works but was unnecessarily complex. I ended up using @11ty/eleventy-img because there is no good way to do this in astro. (my solution can be found here for any curious)
Goals
Example
Api could be something like this:
js import { Image } from '@astrojs/image/components/react';
Beta Was this translation helpful? Give feedback.
All reactions