@democrance/imagemin-lint-staged
v3.0.2
Published
Easily configure imagemin to work with lint-staged
Downloads
138
Readme
@democrance/imagemin-lint-staged
Easily configure imagemin to work with lint-staged
Table of Contents
Install
Install the package locally within you project folder with your package manager:
$ pnpm install -D @democrance/imagemin-lint-staged
You also need to install the default plugins unless you explicitly want to override them:
$ pnpm install -D imagemin-gifsicle imagemin-mozjpeg imagemin-svgo imagemin-optipng
Usage
Configure with lint-staged:
{
"lint-staged": {
"*.{png,jpeg,jpg,gif,svg}": ["imagemin-lint-staged"]
}
}
The package uses cosmiconfig with the module name imagemin
to allow you to configure the imagemin plugins. Add the following to your package.json
{
"imagemin": {
"optipng": {
"optimizationLevel": 5
}
}
}
Your configuration will be merged with the default configuration. If you would like to remove one of the default plugins, add the value of null
and it will be ignored.
{
"imagemin": {
"optipng": null,
"pngout": {}
}
}
Remember to install the imagemin plugins you use. You'll get a warning if their is configuration, but the plugin is missing.
At some cases imagemin plugins won't be able to process your image. In order to omit these files, set $_silentErrors
to true
{
"imagemin": {
"$_silentErrors": true
}
}
If you would like to get more details about the savings, add the --verbose
flag to lint-staged
.
Contributing
Got an idea for a new feature? Found a bug? Contributions are welcome! Please open up an issue or make a pull request.