This commit is contained in:
2021-11-21 11:18:28 +01:00
parent 7a358eb836
commit 230b10b2a3
9339 changed files with 892519 additions and 62 deletions

124
node_modules/gulp-imagemin/index.js generated vendored Normal file
View File

@@ -0,0 +1,124 @@
const path = require('path');
const log = require('fancy-log');
const PluginError = require('plugin-error');
const through = require('through2-concurrent');
const prettyBytes = require('pretty-bytes');
const chalk = require('chalk');
const imagemin = require('imagemin');
const plur = require('plur');
const PLUGIN_NAME = 'gulp-imagemin';
const defaultPlugins = ['gifsicle', 'jpegtran', 'optipng', 'svgo'];
const loadPlugin = (plugin, ...args) => {
try {
return require(`imagemin-${plugin}`)(...args);
} catch (error) {
log(`${PLUGIN_NAME}: Couldn't load default plugin "${plugin}"`);
}
};
const exposePlugin = plugin => (...args) => loadPlugin(plugin, ...args);
const getDefaultPlugins = () =>
defaultPlugins.reduce((plugins, plugin) => {
const instance = loadPlugin(plugin);
if (!instance) {
return plugins;
}
return plugins.concat(instance);
}, []);
module.exports = (plugins, options) => {
if (typeof plugins === 'object' && !Array.isArray(plugins)) {
options = plugins;
plugins = null;
}
options = {
// TODO: Remove this when Gulp gets a real logger with levels
silent: process.argv.includes('--silent'),
verbose: process.argv.includes('--verbose'),
...options
};
const validExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.svg'];
let totalBytes = 0;
let totalSavedBytes = 0;
let totalFiles = 0;
return through.obj({
maxConcurrency: 8
}, (file, encoding, callback) => {
if (file.isNull()) {
callback(null, file);
return;
}
if (file.isStream()) {
callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
return;
}
if (!validExtensions.includes(path.extname(file.path).toLowerCase())) {
if (options.verbose) {
log(`${PLUGIN_NAME}: Skipping unsupported image ${chalk.blue(file.relative)}`);
}
callback(null, file);
return;
}
const localPlugins = plugins || getDefaultPlugins();
(async () => {
try {
const data = await imagemin.buffer(file.contents, {
plugins: localPlugins
});
const originalSize = file.contents.length;
const optimizedSize = data.length;
const saved = originalSize - optimizedSize;
const percent = originalSize > 0 ? (saved / originalSize) * 100 : 0;
const savedMsg = `saved ${prettyBytes(saved)} - ${percent.toFixed(1).replace(/\.0$/, '')}%`;
const msg = saved > 0 ? savedMsg : 'already optimized';
if (saved > 0) {
totalBytes += originalSize;
totalSavedBytes += saved;
totalFiles++;
}
if (options.verbose) {
log(`${PLUGIN_NAME}:`, chalk.green('✔ ') + file.relative + chalk.gray(` (${msg})`));
}
file.contents = data;
callback(null, file);
} catch (error) {
callback(new PluginError(PLUGIN_NAME, error, {fileName: file.path}));
}
})();
}, callback => {
if (!options.silent) {
const percent = totalBytes > 0 ? (totalSavedBytes / totalBytes) * 100 : 0;
let msg = `Minified ${totalFiles} ${plur('image', totalFiles)}`;
if (totalFiles > 0) {
msg += chalk.gray(` (saved ${prettyBytes(totalSavedBytes)} - ${percent.toFixed(1).replace(/\.0$/, '')}%)`);
}
log(`${PLUGIN_NAME}:`, msg);
}
callback();
});
};
module.exports.gifsicle = exposePlugin('gifsicle');
module.exports.jpegtran = exposePlugin('jpegtran');
module.exports.optipng = exposePlugin('optipng');
module.exports.svgo = exposePlugin('svgo');

9
node_modules/gulp-imagemin/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.

67
node_modules/gulp-imagemin/package.json generated vendored Normal file
View File

@@ -0,0 +1,67 @@
{
"name": "gulp-imagemin",
"version": "6.2.0",
"description": "Minify PNG, JPEG, GIF and SVG images",
"license": "MIT",
"repository": "sindresorhus/gulp-imagemin",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"gulpplugin",
"imagemin",
"image",
"img",
"picture",
"photo",
"minify",
"minifier",
"compress",
"png",
"jpg",
"jpeg",
"gif",
"svg"
],
"dependencies": {
"chalk": "^2.4.1",
"fancy-log": "^1.3.2",
"imagemin": "^7.0.0",
"plugin-error": "^1.0.1",
"plur": "^3.0.1",
"pretty-bytes": "^5.3.0",
"through2-concurrent": "^2.0.0"
},
"devDependencies": {
"ava": "^2.3.0",
"get-stream": "^5.1.0",
"imagemin-pngquant": "^8.0.0",
"vinyl": "^2.2.0",
"xo": "^0.24.0"
},
"optionalDependencies": {
"imagemin-gifsicle": "^6.0.1",
"imagemin-jpegtran": "^6.0.0",
"imagemin-optipng": "^7.0.0",
"imagemin-svgo": "^7.0.0"
},
"peerDependencies": {
"gulp": ">=4"
},
"peerDependenciesMeta": {
"gulp": {
"optional": true
}
}
}

129
node_modules/gulp-imagemin/readme.md generated vendored Normal file
View File

@@ -0,0 +1,129 @@
# gulp-imagemin [![Build Status](https://travis-ci.com/sindresorhus/gulp-imagemin.svg?branch=master)](https://travis-ci.com/sindresorhus/gulp-imagemin) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)
> Minify PNG, JPEG, GIF and SVG images with [`imagemin`](https://github.com/imagemin/imagemin)
*Issues with the output should be reported on the [`imagemin` issue tracker](https://github.com/imagemin/imagemin/issues).*
## Install
```
$ npm install --save-dev gulp-imagemin
```
## Usage
### Basic
```js
const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
exports.default = () => (
gulp.src('src/images/*')
.pipe(imagemin())
.pipe(gulp.dest('dist/images'))
);
```
### Custom plugin options
```js
// …
.pipe(imagemin([
imagemin.gifsicle({interlaced: true}),
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 5}),
imagemin.svgo({
plugins: [
{removeViewBox: true},
{cleanupIDs: false}
]
})
]))
// …
```
Note that you may come across an older, implicit syntax. In versions < 3, the same was written like this:
```js
// …
.pipe(imagemin({
interlaced: true,
progressive: true,
optimizationLevel: 5,
svgoPlugins: [
{
removeViewBox: true
}
]
}))
// …
```
### Custom plugin options and custom `gulp-imagemin` options
```js
// …
.pipe(imagemin([
imagemin.svgo({
plugins: [
{
removeViewBox: true
}
]
})
], {
verbose: true
}))
// …
```
## API
Comes bundled with the following **lossless** optimizers:
- [gifsicle](https://github.com/imagemin/imagemin-gifsicle) — *Compress GIF images*
- [jpegtran](https://github.com/imagemin/imagemin-jpegtran) — *Compress JPEG images*
- [optipng](https://github.com/imagemin/imagemin-optipng) — *Compress PNG images*
- [svgo](https://github.com/imagemin/imagemin-svgo) — *Compress SVG images*
These are bundled for convenience and most users will not need anything else.
### imagemin(plugins?, options?)
Unsupported files are ignored.
#### plugins
Type: `Array`<br>
Default: `[imagemin.gifsicle(), imagemin.jpegtran(), imagemin.optipng(), imagemin.svgo()]`
[Plugins](https://www.npmjs.com/browse/keyword/imageminplugin) to use. This will overwrite the default plugins. Note that the default plugins comes with good defaults and should be sufficient in most cases. See the individual plugins for supported options.
#### options
Type: `object`
##### verbose
Type: `boolean`<br>
Default: `false`
Enabling this will log info on every image passed to `gulp-imagemin`:
```
gulp-imagemin: ✔ image1.png (already optimized)
gulp-imagemin: ✔ image2.png (saved 91 B - 0.4%)
```
##### silent
Type: `boolean`<br>
Default: `false`
Don't log the number of images that have been minified.
You can also enable this from the command-line with the `--silent` flag if the option is not already specified.