项目作者: vseventer

项目描述 :
Parcel optimizer plugin to minify images seamlessly.
高级语言: JavaScript
项目地址: git://github.com/vseventer/parcel-optimizer-imagemin.git
创建时间: 2020-12-14T02:08:42Z
项目社区:https://github.com/vseventer/parcel-optimizer-imagemin

开源协议:MIT License

下载


parcel-optimizer-imagemin

Parcel optimizer plugin to minify images seamlessly.

Installation

  1. $ npm install parcel-optimizer-imagemin --save-dev
  2. Update your .parcelrc with the entry below.
    1. "optimizers": {
    2. "*.{gif,jpeg,jpg,png,svg,webp}": ["parcel-optimizer-imagemin", "..."]
    3. }

Important: the three dots indicate to Parcel to run their default optimizers on any bundles that haven’t been optimized yet.

Configuration

Plugin configuration lives in your package.json, as parcel-optimizer-imagemin object prop:

  • Keys should be imagemin plugins.
  • Values should be a plugin options object, or false to disable the plugin.

Preset Plugins

By default, this optimizer includes the following imagemin configuration:

  1. {
  2. "imagemin-gifsicle": { "optimizationLevel": 3 },
  3. "imagemin-mozjpeg": { "quality": 80 },
  4. "imagemin-pngquant": { "speed": 1, "strip": true },
  5. "imagemin-svgo": {},
  6. "imagemin-webp": {}
  7. }

Examples

The example below shows how to use optipng instead of pngquant.

  1. // package.json
  2. "parcel-optimizer-imagemin": {
  3. "imagemin-optipng": {},
  4. "imagemin-pngquant": false
  5. }

Important: optipng is not installed by default, and you should add this dependency to your package.json.

Debugging

Run Parcel with --log-level info to see what and how bundles are optimized.

Changelog

See the Changelog for a list of changes.

License

  1. The MIT License (MIT)
  2. Copyright (c) 2020 Mark van Seventer
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of
  4. this software and associated documentation files (the "Software"), to deal in
  5. the Software without restriction, including without limitation the rights to
  6. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  7. the Software, and to permit persons to whom the Software is furnished to do so,
  8. subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  13. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  14. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  15. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.