farm-plugin-webp-to-png
A Rust plugin for Farm that can:
- convert
.webpassets to.png - rewrite
.webpreferences to.pngduring production build - compress all
.pngassets - optionally recompress
.webpassets as smaller WebP files when conversion is disabled
Install
pnpm add -D farm-plugin-webp-to-png
Usage
import { defineConfig } from "@farmfe/core";
import webpToPng from "farm-plugin-webp-to-png";
export default defineConfig({
plugins: [
webpToPng()
],
});
Options
import { defineConfig } from "@farmfe/core";
import webpToPng from "farm-plugin-webp-to-png";
export default defineConfig({
plugins: [
webpToPng({
is_convert: false,
quality: 80,
}),
],
});
is_convert
- type:
boolean - default:
false
When is_convert is true:
.webpassets are converted to.png.webpreferences in generated content are replaced with.png- all
.pngassets are compressed
When is_convert is false:
.webpassets stay as.webp.webpassets are recompressed with WebP lossy encoding- all
.pngassets are compressed
quality
- type:
number - default:
80 - range:
0 ~ 100
Used only when is_convert is false.
A lower value gives smaller output size with lower image quality. A higher value gives better image quality with larger output size.