1.0.2 • Published 5 years ago
@nonsugarless/manage-webp v1.0.2
DEPRECATED
This package was moved to @nonsugarless/webp-converter and will be no maintained. You can use the new one in the same way.
Features
You can convert images to WebP Images and delete unnecessary WebP Images automatically.
Installation
npm install @nonsugarless/manage-webpUsage
Convert all images
$ mwebp convertStart to watch images directory
$ mwebp watchWebP Images will be converted automatically when images are added, changed and deleted.
Delete converted WebP Images
$ mwebp cleanDelete converted WebP Images whose original one no longer exists in originalDir
$ mwebp clean --allDelete all WebP Images from destDir
Default configuration
| Prop | Default | Description |
|---|---|---|
destDir | "./htdocs/img/" | Path to output images directory from project root |
originalDir | "./htdocs/img/" | Path to input images directory from project root |
targetExt | ".+(jpg|jpeg|png|gif)" | Extension of convert files |
excludeFileNames | "apple-touch-icon.png" | Array of filenames that you don't want to convert |
excludeDirNames | [] | Array of relative path from originalDir that you don't want to convert |
webpConverterOption | "-q 85" | WebP convert options |
webpConverterGifOption | "-q 85" | Gif WebP convert options |
Optional configuration
You can use an optional configuration .managewebprc file in JSON or YAML format or managewebp.config.js file exporting a JS object by setting it project root directory.
{
"destDir": "./dest/img/",
"originalDir": "./src/img/",
"targetExt": ".+(jpg|png|gif)",
"excludeFileNames": ["apple-touch-icon.png", "og-image.png"],
"excludeDirNames": ["foo/bar"], // ignore all files below ./dest/img/foo/bar/
"webpConverterOption": "-q 75 -sharp_yuv -m 5 -mt",
"webpConverterGifOption": "-q 90 -m 5 -mt"
}