Galerie und tage
This commit is contained in:
53
node_modules/imagemin-svgo/index.js
generated
vendored
53
node_modules/imagemin-svgo/index.js
generated
vendored
@@ -1,18 +1,47 @@
|
||||
'use strict';
|
||||
const isSvg = require('is-svg');
|
||||
const SVGO = require('svgo');
|
||||
|
||||
module.exports = options => buffer => {
|
||||
options = Object.assign({multipass: true}, options);
|
||||
var isSvg = require('is-svg');
|
||||
var SVGO = require('svgo');
|
||||
var through = require('through2');
|
||||
|
||||
if (!isSvg(buffer)) {
|
||||
return Promise.resolve(buffer);
|
||||
}
|
||||
module.exports = function (opts) {
|
||||
opts = opts || {};
|
||||
|
||||
if (Buffer.isBuffer(buffer)) {
|
||||
buffer = buffer.toString();
|
||||
}
|
||||
return through.ctor({objectMode: true}, function (file, enc, cb) {
|
||||
if (file.isNull()) {
|
||||
cb(null, file);
|
||||
return;
|
||||
}
|
||||
|
||||
const svgo = new SVGO(options);
|
||||
return svgo.optimize(buffer).then(result => Buffer.from(result.data));
|
||||
if (file.isStream()) {
|
||||
cb(new Error('Streaming is not supported'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isSvg(file.contents)) {
|
||||
cb(null, file);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var svgo = new SVGO(opts);
|
||||
|
||||
svgo.optimize(file.contents.toString('utf8'), function (res) {
|
||||
if (!res.data || !res.data.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
res.data = res.data.replace(/&(?!amp;)/g, '&');
|
||||
res.data = new Buffer(res.data);
|
||||
|
||||
file.contents = res.data;
|
||||
});
|
||||
} catch (err) {
|
||||
err.fileName = file.path;
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
cb(null, file);
|
||||
});
|
||||
};
|
||||
|
||||
22
node_modules/imagemin-svgo/license
generated
vendored
22
node_modules/imagemin-svgo/license
generated
vendored
@@ -1,9 +1,21 @@
|
||||
MIT License
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Imagemin (github.com/imagemin)
|
||||
Copyright (c) imagemin
|
||||
|
||||
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:
|
||||
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 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.
|
||||
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.
|
||||
|
||||
83
node_modules/imagemin-svgo/package.json
generated
vendored
83
node_modules/imagemin-svgo/package.json
generated
vendored
@@ -1,34 +1,53 @@
|
||||
{
|
||||
"name": "imagemin-svgo",
|
||||
"version": "7.1.0",
|
||||
"description": "SVGO imagemin plugin",
|
||||
"license": "MIT",
|
||||
"repository": "imagemin/imagemin-svgo",
|
||||
"funding": "https://github.com/sindresorhus/imagemin-svgo?sponsor=1",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"compress",
|
||||
"image",
|
||||
"imageminplugin",
|
||||
"minify",
|
||||
"optimize",
|
||||
"svg",
|
||||
"svgo"
|
||||
],
|
||||
"dependencies": {
|
||||
"is-svg": "^4.2.1",
|
||||
"svgo": "^1.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.0.0",
|
||||
"xo": "^0.20.0"
|
||||
}
|
||||
"name": "imagemin-svgo",
|
||||
"version": "4.2.1",
|
||||
"description": "SVGO imagemin plugin",
|
||||
"license": "MIT",
|
||||
"repository": "imagemin/imagemin-svgo",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "github.com/kevva"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
{
|
||||
"name": "Shinnosuke Watanabe",
|
||||
"url": "github.com/shinnn"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"compress",
|
||||
"gulpplugin",
|
||||
"image",
|
||||
"imageminplugin",
|
||||
"img",
|
||||
"minify",
|
||||
"optimize",
|
||||
"svg",
|
||||
"svgo"
|
||||
],
|
||||
"dependencies": {
|
||||
"is-svg": "^1.0.0",
|
||||
"svgo": "^0.6.0",
|
||||
"through2": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"vinyl": "^1.1.0",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
|
||||
52
node_modules/imagemin-svgo/readme.md
generated
vendored
52
node_modules/imagemin-svgo/readme.md
generated
vendored
@@ -1,54 +1,52 @@
|
||||
# imagemin-svgo [](https://travis-ci.org/imagemin/imagemin-svgo)
|
||||
# imagemin-svgo [](https://travis-ci.org/imagemin/imagemin-svgo) [](https://ci.appveyor.com/project/ShinnosukeWatanabe/imagemin-svgo/branch/master)
|
||||
|
||||
> [SVGO](https://github.com/svg/svgo) imagemin plugin
|
||||
|
||||
> [svgo](https://github.com/svg/svgo) imagemin plugin
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install imagemin-svgo
|
||||
$ npm install --save imagemin-svgo
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const imagemin = require('imagemin');
|
||||
const Imagemin = require('imagemin');
|
||||
const imageminSvgo = require('imagemin-svgo');
|
||||
|
||||
(async () => {
|
||||
await imagemin(['images/*.svg'], 'build/images', {
|
||||
use: [
|
||||
imageminSvgo({
|
||||
plugins: [
|
||||
{removeViewBox: false}
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
new Imagemin()
|
||||
.src('images/*.svg')
|
||||
.dest('build/images')
|
||||
.use(imageminSvgo())
|
||||
.run();
|
||||
```
|
||||
|
||||
console.log('Images optimized');
|
||||
})();
|
||||
You can also use this plugin with [gulp](http://gulpjs.com):
|
||||
|
||||
```js
|
||||
const gulp = require('gulp');
|
||||
const imageminSvgo = require('imagemin-svgo');
|
||||
|
||||
gulp.task('default', () => {
|
||||
return gulp.src('images/*.svg')
|
||||
.pipe(imageminSvgo()())
|
||||
.pipe(gulp.dest('build/images'));
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### imageminSvgo([options])(buffer)
|
||||
|
||||
Returns a `Promise<Buffer>`.
|
||||
### imageminSvgo(options)
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
Type: `object`
|
||||
|
||||
Pass options to [SVGO](https://github.com/svg/svgo#what-it-can-do).
|
||||
|
||||
#### buffer
|
||||
|
||||
Type: `Buffer`
|
||||
|
||||
Buffer to optimize.
|
||||
Pass options to [svgo](https://github.com/svg/svgo#what-it-can-do).
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Reference in New Issue
Block a user