Skip to content
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

Generate webp on the fly #29

Open
lucalbert opened this issue Dec 31, 2020 · 3 comments
Open

Generate webp on the fly #29

lucalbert opened this issue Dec 31, 2020 · 3 comments

Comments

@lucalbert
Copy link

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

@ai
Copy link
Owner

ai commented Dec 31, 2020

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.

@lucalbert
Copy link
Author

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.

@ai
Copy link
Owner

ai commented Jan 14, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants