webp-in-css icon indicating copy to clipboard operation
webp-in-css copied to clipboard

Generate webp on the fly

Open lucalbert opened this issue 4 years ago • 3 comments

Hello,

Is there no way to generate the webp images on the fly instead of having to generate them first?

I'm using WebPack with postcss-loader (through webpack-encore) and I have the ImageminWebpWebpackPlugin plugin which already converts JPE?G/PNG to webp on the fly.

Thanks

lucalbert avatar Dec 31 '20 14:12 lucalbert

There are many ways, but I do not have any particular recommendation for all cases. For instance, you can create a pre-commit hook or run a script before calling PostCSS.

ai avatar Dec 31 '20 19:12 ai

Hi @ai,

Ok, thanks, I'll take a look at this.

On the other hand, it may be a misunderstanding of the postCSS workflow with Webpack, but if I understand correctly, PostCSS performs its processing after Webpack has done its work (therefore on the files that are in the build directory)?

So why do the webp images have to be in the source directory? Can't it work directly with webp images in the build directory?

Many thanks.

lucalbert avatar Jan 14 '21 09:01 lucalbert

If I understand correctly, PostCSS performs its processing after Webpack has done its work (therefore on the files that are in the build directory)

Nope. PostCSS works inside webpack processing via postcss-loader.

So why do the webp images have to be in the source directory?

Maybe image loader works after postcss-loader

ai avatar Jan 14 '21 10:01 ai