opennextjs / opennextjs-cloudflare

Open Next.js adapter for Cloudflare
https://opennext.js.org/cloudflare
MIT License
417 stars 12 forks source link

Image optimization #106

Open vicb opened 1 month ago

vicb commented 1 month ago

Support Image Optimization on the cloudflare infra

Refs:

conico974 commented 1 month ago

The aws implementation would probably not work as is on cloudflare ( It uses next and sharp ).

I had some plan to update the image optimization stuff to be more flexible. The idea would be to replace the current next/sharp implementation with a custom override ( default would stay as is )

It would also make sense to change the way we install native deps. Right now for the image optimization it runs npm i sharp for the desired arch/target. The idea would be to make this more generic so that you could choose for every part what you'd like to install and for which arch/target. An option for every function in open-next.config.ts (server/middleware/imageOptimization ... ) in this form would make sense :

install : {
 packages: ['sharp', ...],
 arch: 'arm'|'x64',
}

Obviously for cloudflare you'll override the default with what's appropriate depending on what end up being decided here

khalil-omer commented 1 month ago

Shouldn't the implementation of image optimization simply use Cloudflare Images? This can be done manually, but maybe it can also be done after the base build is complete, via the Cloudflare build.

vicb commented 1 month ago

Shouldn't the implementation of image optimization simply use Cloudflare Images?

Yes that's the plan