Easily configure imagemin to work with lint-staged
This project uses node and npm.
$ npm install -D lint-staged-imagemin
You also need to install the default plugins unless you explicity want to override them:
$ npm install -D imagemin-gifsicle imagemin-mozjpeg imagemin-svgo imagemin-optipng
Configure with lint-staged:
{
"lint-staged": {
"*.{png,jpeg,jpg,gif,svg}": ["lint-staged-imagemin"]
},
}
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.
If you would like to get more details about the savings, add the --verbose
flag to lint-staged
.
- Fork it and create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am "Add some feature"
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
MIT