iampava / imagemin-webp-webpack-plugin

Webpack plugin which converts images to the WebP format while also keeping the original files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Append ".webp" to [filename] + [extension] instead of replacing extension

TheodorTomas opened this issue · comments

Do you want to request a feature or report a bug?

Possible bug/Feature idea

What is the current behaviour?

Replaces extension to "webp" format.

"checkmark-icon.jpg" => "checkmark-icon.webp"

What is the expected behaviour?

Append ".webp" to [filename] + [extension] to ensure uniqueness. This would prevent files with same name but different extensions overwriting the output of the .webp conversion output.

Example:

"checkmark-icon.jpg" => "checkmark-icon.jpg.webp"
"checkmark-icon.png" => "checkmark-icon.png.webp"

Hey,

I get your point but I don't think this is an issue that should be handled by the plugin. I mean, why would you have the same image in different formats? In what use case would you use both?

I know this is old, but just a quick comment, you may want to have a fallback jpg for older browsers, but just the extension change should be fine.

Yes indeed, But I think he was referring to having an image in more than one format, for example: jpeg and png. I don't see a usecase for that to be honest.

Usually you'd have just one well-supported format as a fallback, and then a newer format like webp or the even newer avif.

Hey,
My example is this. I have a folder with two images containing the same name for two different extensions, lets say profile.jpg and profile.png, and I would like to convert them both to .webp format. This extension will then not work correctly since it will discard the original extension information when converting to webp.

i.e. profile.jpg and profile.png will both result in creating profile.webp. This is quite inconvenient and IMO is something the plugin should guard against. But I found a workaround by having webpack add the extension type to the filename before formatting to webp so it is not something I require anymore.

Hope that explains my situation a little bit better.

Yes indeed, But I think he was referring to having an image in more than one format, for example: jpeg and png. I don't see a usecase for that to be honest.

Usually you'd have just one well-supported format as a fallback, and then a newer format like webp or the even newer avif.

Yeah I agree, one fallback sounds reasonable.