1.1.0 • Published 2 years ago

@democrance/image-lint-staged v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

lint-staged-imagemin

package version package downloads standard-readme compliant package license make a pull request

Easily configure imagemin to work with lint-staged

Table of Contents

Install

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

Usage

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.

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT