Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,67 @@
# 2.1.6
* Resolves an issue where postcss-svgo would convert colours to hex codes
without URL-encoding the `#`.
# 2.1.5
* Bump svgo to v0.7.x.
# 2.1.4
* Fixes an issue where postcss-svgo would throw with some SVGs that were
not properly URI encoded.
# 2.1.3
* Upgrade is-svg to version 2.
# 2.1.2
* Fixes an issue with processing some malformed URIs (thanks to @TrySound).
# 2.1.1
* Bump SVGO to 0.6.1 (thanks to @shinnn).
# 2.1.0
* Adds `encode` option (thanks to @TrySound).
# 2.0.4
* Updates postcss-value-parser to version 3 (thanks to @TrySound).
# 2.0.3
* Uses postcss-value-parser instead of async-replace to reduce cssnano's
download size (thanks to @TrySound).
# 2.0.2
* Fixed an issue where the module was not handling exceptions from
decoding URLs.
* The module will now convert all SVG wrapping quotes to single quotes, which
is consistent with SVGO's output.
# 2.0.1
* Fixed an issue where the `charset` definition was being removed from the
SVG source, breaking IE compatibility (thanks to @ophyros).
# 2.0.0
* Upgraded to PostCSS 5.0.
# 1.1.0
* Adds support for uri-encoded SVG files, for better compatibility
with postcss-svg.
# 1.0.1
* Push ES5 build to npm.
# 1.0.0
* Initial release.

View File

@@ -0,0 +1,22 @@
Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
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.

View File

@@ -0,0 +1,130 @@
# [postcss][postcss]-svgo [![Build Status](https://travis-ci.org/ben-eb/postcss-svgo.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-svgo.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-svgo.svg)][deps]
> Optimise inline SVG with PostCSS.
## Install
With [npm](https://npmjs.org/package/postcss-svgo) do:
```
npm install postcss-svgo --save
```
## Example
### Input
```css
h1 {
background: url('data:image/svg+xml;charset=utf-8,<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"><circle cx="50" cy="50" r="40" fill="yellow" /></svg>');
}
```
### Output
```css
h1 {
background: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="%23ff0"/></svg>');
}
```
## API
### `svgo([options])`
Note that postcss-svgo is an *asynchronous* processor. It cannot be used
like this:
```js
var result = postcss([ svgo() ]).process(css).css;
console.log(result);
```
Instead make sure your PostCSS runner uses the asynchronous API:
```js
postcss([ svgo() ]).process(css).then(function (result) {
console.log(result.css);
});
```
#### options
##### encode
Type: `boolean`
Default: `undefined`
If `true`, it will encode URL-unsafe characters such as `<`, `>` and `&`;
`false` will decode these characters, and `undefined` will neither encode nor
decode the original input. Note that regardless of this setting, `#` will
always be URL-encoded.
##### plugins
Optionally, you can customise the output by specifying the `plugins` option. You
will need to provide the config in comma separated objects, like the example
below. Note that you can either disable the plugin by setting it to `false`,
or pass different options to change the default behaviour.
```js
var postcss = require('postcss');
var svgo = require('postcss-svgo');
var opts = {
plugins: [{
removeDoctype: false
}, {
removeComments: false
}, {
cleanupNumericValues: {
floatPrecision: 2
}
}, {
convertColors: {
names2hex: false,
rgb2hex: false
}
}]
};
postcss([ svgo(opts) ]).process(css).then(function (result) {
console.log(result.css)
});
```
You can view the [full list of plugins here][plugins].
## Usage
See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
examples for your environment.
## Contributors
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/ben-eb/postcss-svgo/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-svgo/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-svgo/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/7263665?v=3" width="100px;"/><br /><sub>Sebastian Misch</sub>](https://sebastian-misch.de)<br />[💻](https://github.com/ben-eb/postcss-svgo/commits?author=sbstnmsch) [⚠️](https://github.com/ben-eb/postcss-svgo/commits?author=sbstnmsch) | [<img src="https://avatars.githubusercontent.com/u/11319202?v=3" width="100px;"/><br /><sub>Вячеслав Ляшенко</sub>](https://github.com/ophyros)<br />[💻](https://github.com/ben-eb/postcss-svgo/commits?author=ophyros) [⚠️](https://github.com/ben-eb/postcss-svgo/commits?author=ophyros) | [<img src="https://avatars.githubusercontent.com/u/1131567?v=3" width="100px;"/><br /><sub>shinnn</sub>](https://shinnn.github.io)<br />[💻](https://github.com/ben-eb/postcss-svgo/commits?author=shinnn) | [<img src="https://avatars.githubusercontent.com/u/45338?v=3" width="100px;"/><br /><sub>Jung-gun Lim</sub>](https://github.com/j6lim)<br />[🐛](https://github.com/ben-eb/postcss-svgo/issues?q=author%3Aj6lim) | [<img src="https://avatars.githubusercontent.com/u/5635476?v=3" width="100px;"/><br /><sub>Bogdan Chadkin</sub>](https://github.com/TrySound)<br />[💻](https://github.com/ben-eb/postcss-svgo/commits?author=TrySound) 👀 [⚠️](https://github.com/ben-eb/postcss-svgo/commits?author=TrySound) | [<img src="https://avatars.githubusercontent.com/u/368561?v=3" width="100px;"/><br /><sub>Piotr Walczyszyn</sub>](http://outof.me)<br />[🐛](https://github.com/ben-eb/postcss-svgo/issues?q=author%3Apwalczyszyn) |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors] specification. Contributions of
any kind welcome!
## License
MIT © [Ben Briggs](http://beneb.info)
[all-contributors]: https://github.com/kentcdodds/all-contributors
[ci]: https://travis-ci.org/ben-eb/postcss-svgo
[deps]: https://gemnasium.com/ben-eb/postcss-svgo
[npm]: http://badge.fury.io/js/postcss-svgo
[postcss]: https://github.com/postcss/postcss
[plugins]: https://github.com/svg/svgo/tree/master/plugins

View File

@@ -0,0 +1,108 @@
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _postcss = require('postcss');
var _postcss2 = _interopRequireDefault(_postcss);
var _postcssValueParser = require('postcss-value-parser');
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
var _svgo = require('svgo');
var _svgo2 = _interopRequireDefault(_svgo);
var _isSvg = require('is-svg');
var _isSvg2 = _interopRequireDefault(_isSvg);
var _url = require('./lib/url');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var PLUGIN = 'postcss-svgo';
var dataURI = /data:image\/svg\+xml(;(charset=)?utf-8)?,/;
function minifyPromise(svgo, decl, opts) {
var promises = [];
decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) {
if (node.type !== 'function' || node.value !== 'url' || !node.nodes.length) {
return;
}
var value = node.nodes[0].value;
var decodedUri = void 0,
isUriEncoded = void 0;
try {
decodedUri = (0, _url.decode)(value);
isUriEncoded = decodedUri !== value;
} catch (e) {
// Swallow exception if we cannot decode the value
isUriEncoded = false;
}
if (isUriEncoded) {
value = decodedUri;
}
if (opts.encode !== undefined) {
isUriEncoded = opts.encode;
}
var svg = value.replace(dataURI, '');
if (!(0, _isSvg2.default)(svg)) {
return;
}
promises.push(new Promise(function (resolve, reject) {
return svgo.optimize(svg, function (result) {
if (result.error) {
return reject(PLUGIN + ': ' + result.error);
}
var data = isUriEncoded ? (0, _url.encode)(result.data) : result.data;
// Should always encode # otherwise we yield a broken SVG
// in Firefox (works in Chrome however). See this issue:
// https://github.com/ben-eb/cssnano/issues/245
data = data.replace(/#/g, '%23');
node.nodes[0] = _extends({}, node.nodes[0], {
value: 'data:image/svg+xml;charset=utf-8,' + data,
quote: isUriEncoded ? '"' : '\'',
type: 'string',
before: '',
after: ''
});
return resolve();
});
}));
return false;
});
return Promise.all(promises).then(function () {
return decl.value = decl.value.toString();
});
}
exports.default = _postcss2.default.plugin(PLUGIN, function () {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var svgo = new _svgo2.default(opts);
return function (css) {
return new Promise(function (resolve, reject) {
var promises = [];
css.walkDecls(function (decl) {
if (dataURI.test(decl.value)) {
promises.push(minifyPromise(svgo, decl, opts));
}
});
return Promise.all(promises).then(resolve, reject);
});
};
});
module.exports = exports['default'];

View File

@@ -0,0 +1,9 @@
'use strict';
exports.__esModule = true;
exports.encode = encode;
function encode(data) {
return data.replace(/"/g, '\'').replace(/%/g, '%25').replace(/</g, '%3C').replace(/>/g, '%3E').replace(/&/g, '%26').replace(/#/g, '%23').replace(/\s+/g, ' ');
};
var decode = exports.decode = decodeURIComponent;

View File

@@ -0,0 +1,101 @@
{
"_args": [
[
"postcss-svgo@2.1.6",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "postcss-svgo@2.1.6",
"_id": "postcss-svgo@2.1.6",
"_inBundle": false,
"_integrity": "sha1-tt8YqmE7Zm4TPwittSGcJoSsEI0=",
"_location": "/css-loader/postcss-svgo",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "postcss-svgo@2.1.6",
"name": "postcss-svgo",
"escapedName": "postcss-svgo",
"rawSpec": "2.1.6",
"saveSpec": null,
"fetchSpec": "2.1.6"
},
"_requiredBy": [
"/css-loader/cssnano"
],
"_resolved": "https://registry.npmjs.org/postcss-svgo/-/postcss-svgo-2.1.6.tgz",
"_spec": "2.1.6",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Ben Briggs",
"email": "beneb.info@gmail.com",
"url": "http://beneb.info"
},
"ava": {
"require": "babel-register"
},
"bugs": {
"url": "https://github.com/ben-eb/postcss-svgo/issues"
},
"dependencies": {
"is-svg": "^2.0.0",
"postcss": "^5.0.14",
"postcss-value-parser": "^3.2.3",
"svgo": "^0.7.0"
},
"description": "Optimise inline SVG with PostCSS.",
"devDependencies": {
"all-contributors-cli": "^3.0.5",
"ava": "^0.16.0",
"babel-cli": "^6.4.5",
"babel-core": "^6.4.5",
"babel-plugin-add-module-exports": "^0.2.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.9.0",
"coveralls": "^2.11.6",
"del-cli": "^0.2.0",
"eslint": "^3.0.0",
"eslint-config-cssnano": "^3.0.0",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^2.0.1",
"nyc": "^10.0.0",
"pleeease-filters": "^3.0.0"
},
"eslintConfig": {
"extends": "cssnano"
},
"files": [
"LICENSE-MIT",
"dist"
],
"homepage": "https://github.com/ben-eb/postcss-svgo",
"keywords": [
"css",
"minify",
"optimise",
"postcss",
"postcss-plugin",
"svg",
"svgo"
],
"license": "MIT",
"main": "dist/index.js",
"name": "postcss-svgo",
"repository": {
"type": "git",
"url": "git+https://github.com/ben-eb/postcss-svgo.git"
},
"scripts": {
"contributorAdd": "all-contributors add",
"contributorGenerate": "all-contributors generate",
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
"pretest": "eslint src",
"report": "nyc report --reporter=html",
"test": "nyc --reporter=text ava src/__tests__",
"test-012": "nyc --reporter=text ava src/__tests__"
},
"version": "2.1.6"
}