Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ixkaito/imagemin
Minify images seamlessly while preserving directory structure
https://github.com/ixkaito/imagemin
Last synced: 26 days ago
JSON representation
Minify images seamlessly while preserving directory structure
- Host: GitHub
- URL: https://github.com/ixkaito/imagemin
- Owner: ixkaito
- License: mit
- Created: 2020-03-04T08:15:33.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-03-04T17:53:58.000Z (over 4 years ago)
- Last Synced: 2024-10-05T16:40:16.804Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @ixkaito/imagemin
> Minify images seamlessly while preserving directory structure
Based on [`imagemin`](https://github.com/imagemin/imagemin) but preserves directory structure. Inspired by [`imagemin-dir`](https://github.com/adamduncan/imagemin-dir).
## Install
```
$ npm install @ixkaito/imagemin
```## Usage
```js
const imagemin = require('@ixkaito/imagemin'); // alternative to imagemin
const imageminJpegtran = require('imagemin-jpegtran');
const imageminPngquant = require('imagemin-pngquant');(async () => {
const files = await imagemin(['images/*.{jpg,png}'], {
destination: 'build/images',
plugins: [
imageminJpegtran(),
imageminPngquant({
quality: [0.6, 0.8]
})
]
});console.log(files);
//=> [{data: , destinationPath: 'build/images/foo.jpg'}, …]
})();
```## Destination Path Examples
input: `'assets/_images/**/*'`
destination: `'assets/images'`
```
assets/_images/foo.jpg -> assets/images/foo.jpg
assets/_images/foo/bar.jpg -> assets/images/foo/bar.jpg
assets/_images/foo/bar/baz.jpg -> assets/images/foo/bar/baz.jpg
```input: `['source/**/*.{jpg,png,svg}', 'assets/**/*.{jpg,png,svg}']`
destination: `'dist/assets'`
```
source/images/foo.jpg -> dist/assets/images/foo.jpg
source/images/foo.png -> dist/assets/images/foo.png
source/svg/foo.svg -> dist/assets/svg/foo.svg
assets/images/bar.jpg -> dist/assets/images/bar.jpg
assets/images/bar.png -> dist/assets/images/bar.png
assets/svg/bar.svg -> dist/assets/svg/bar.svg
```## API
`@ixkaito/imagemin` maintains the same API as `imagemin`. See https://github.com/imagemin/imagemin.