Plugin should support using a generator for svg -> webp conversions (when using sharp)
la-magra opened this issue · 3 comments
la-magra commented
Feature Proposal
This is halfway bug-report and feature request.
Right now configuring
// webpack.config.js
new ImageMinimizerPlugin({
generator: [
{
preset: 'webp',
implementation: ImageMinimizerPlugin.sharpGenerate,
options: {
encodeOptions: {
webp: {
quality: 90,
},
},
},
}
]
}),
and using it on
// test.vue
<template lang="pug">
img(
src="./../test.svg?as=webp"
)
</template>
returns the following error
ERROR Failed to compile with 1 error
error in ../test.svg?as=webp
Module Error (from ../node_modules/image-minimizer-webpack-plugin/dist/loader.js):
Error with '/home/---/-/test.svg': Input file has an unsupported format
even as sharp supports converting svg's to webp.
Feature Use Case
Extremely useful, some very complex svgs can be over 200KiB but converted to webp or png they can be less than 20KiB.
Please paste the results of npx webpack-cli info
here, and mention other relevant information
$ npx webpack-cli info
System:
OS: Linux 6.1 Arch Linux
CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Memory: 8.11 GB / 15.56 GB
Binaries:
Node: 16.19.1 - ~/.cache/node/bin/node
Yarn: 3.4.1 - ~/.cache/node/bin/yarn
npm: 8.19.3 - ~/.cache/node/bin/npm
Browsers:
Firefox: 110.0
Monorepos:
Yarn Workspaces: 3.4.1
Packages:
image-minimizer-webpack-plugin: ^3.8.1 => 3.8.1
alexander-akait commented
It means sharp doesn't support svg -> webp... but based on documentation it should work, I will check
alexander-akait commented
la-magra commented
Wonderful, thank you.