# optimize-image-webpack-loader

> Optimize image loader module for webpack

Latest version **0.1.9** (published 2019-07-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install optimize-image-webpack-loader
pnpm add optimize-image-webpack-loader
yarn add optimize-image-webpack-loader
bun add optimize-image-webpack-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.9 |
| Published | 2019-07-29 |
| First published | 2018-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6.9.0 <7.0.0 \|\| >= 8.9.0 |
| Dependencies | 3 |
| Unpacked size | 18.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | José Massada |
| Maintainers | massada |
| Keywords | sharp, optimize, image, webpack, loader |

## Links

- npm: https://www.npmjs.com/package/optimize-image-webpack-loader
- Repository: https://github.com/massada/optimize-image-webpack-loader
- Issues: https://github.com/massada/optimize-image-webpack-loader/issues
- npm.io page: https://npm.io/package/optimize-image-webpack-loader

## Dependencies (3)

- [cacache](https://npm.io/package/cacache.md) ^12.0.2
- [loader-utils](https://npm.io/package/loader-utils.md) ^1.1.0
- [find-cache-dir](https://npm.io/package/find-cache-dir.md) ^3.0.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.1.9 (latest) — 2019-07-29
- 0.1.8 — 2019-07-14
- 0.1.7 — 2019-07-14
- 0.1.6 — 2018-12-07
- 0.1.5 — 2018-12-06
- 0.1.4 — 2018-12-05
- 0.1.3 — 2018-11-24
- 0.1.2 — 2018-11-24
- 0.1.1 — 2018-08-30
- 0.1.0 — 2018-08-30

## README

# optimize-image-webpack-loader
A image loader module for webpack.

## Requirements

This module requires a minimum of Node v6.9.0 and works with Webpack v3 and Webpack v4.

## Getting Started

### npm
```console
$ npm install optimize-image-webpack-loader
```

### yarn
```console
$ yarn add optimize-image-webpack-loader
```

## Options

### `name`
Type: `String`
Default: `'[name].[hash:8].[ext]'`

Specifies a custom image filename template for the target file(s) using the
query parameter `name`.

### `sharp`
Type: `Object`
Default: `{}`

Overwrites sharp options.

See (https://github.com/lovell/sharp/blob/master/lib/constructor.js) for
defaults.

### `widths`
Type: `Number|Array`
Default: `undefined`

Specifies the output image(s) width, defaults to loaded image width.

## Usage

### Example 1
```js
const config = {
  ...
  module: {
    rules: [
      {
        test: /\.(png|jpe?g|gif|tiff)$/,
        loader: 'optimize-image-webpack-loader',
        options: {
          name: 'images/[name].[hash:8].[ext]',
          sharp: {
            jpegQuality: 85,
            jpegProgressive: true,
            jpegChromaSubsampling: '4:2:0'
          },
          widths: [2000, 1000],
        },
      },
    ],
  },
  ...
};
```

### Example 2
```js
const url = require('./image.jpg?{widths:[500,250]}');
```

### Example 4
```js
const url = require('./image.jpg?{widths:125}');
```

## Changelog
See [Changelog](./CHANGELOG.md).

## License
Copyright (c) 2018 José Massada <jose.massada@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/optimize-image-webpack-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
