diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:38:48 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 21:53:09 +0800 |
| commit | 26105034da4fcce7ac883c899d781f016559310d (patch) | |
| tree | c459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/postcss-reduce-idents | |
| parent | 2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff) | |
| download | xmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip | |
switch to vuepress
Diffstat (limited to 'node_modules/postcss-reduce-idents')
| -rw-r--r-- | node_modules/postcss-reduce-idents/CHANGELOG.md | 50 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/LICENSE-MIT | 22 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/README.md | 149 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/dist/index.js | 62 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/dist/lib/cache.js | 15 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/dist/lib/counter-style.js | 65 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/dist/lib/counter.js | 92 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/dist/lib/encode.js | 22 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/dist/lib/grid-template.js | 78 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/dist/lib/isNum.js | 11 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/dist/lib/keyframes.js | 65 | ||||
| -rw-r--r-- | node_modules/postcss-reduce-idents/package.json | 57 |
12 files changed, 688 insertions, 0 deletions
diff --git a/node_modules/postcss-reduce-idents/CHANGELOG.md b/node_modules/postcss-reduce-idents/CHANGELOG.md new file mode 100644 index 00000000..c725e9fd --- /dev/null +++ b/node_modules/postcss-reduce-idents/CHANGELOG.md @@ -0,0 +1,50 @@ +# 2.4.0 + +* Adds support for reducing `grid` identifiers + (thanks to @sylvainpolletvillard). + +# 2.3.1 + +* Performance tweaks: now performs one AST pass instead of three. + +# 2.3.0 + +* Adds support for a custom encoder function (thanks to @rauchg). + +# 2.2.2 + +* Now compiled with babel 6. + +# 2.2.1 + +* Updates postcss-value-parser to version 3 (thanks to @TrySound). + +# 2.2.0 + +* Added options for customising what the module reduces (thanks to @TrySound). +* Replaced regex number test with postcss-value-parser unit method. + +# 2.1.0 + +* Replaced reduce-function-call with postcss-value-parser (thanks to @TrySound). + +# 2.0.0 + +* Upgraded to PostCSS 5. + +# 1.0.3 + +* Improved performance by iterating the AST less times. + +# 1.0.2 + +* Fixes an issue where multiple, comma separated animations with insufficient + whitespace were not being renamed. + +# 1.0.1 + +* Documentation/metadata tweaks for plugin guidelines compatibility. + +# 1.0.0 + +* Initial release. diff --git a/node_modules/postcss-reduce-idents/LICENSE-MIT b/node_modules/postcss-reduce-idents/LICENSE-MIT new file mode 100644 index 00000000..fd0e863a --- /dev/null +++ b/node_modules/postcss-reduce-idents/LICENSE-MIT @@ -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. diff --git a/node_modules/postcss-reduce-idents/README.md b/node_modules/postcss-reduce-idents/README.md new file mode 100644 index 00000000..c49b8889 --- /dev/null +++ b/node_modules/postcss-reduce-idents/README.md @@ -0,0 +1,149 @@ +# [postcss][postcss]-reduce-idents [][ci] [][npm] [][deps] + +> Reduce [custom identifiers][idents] with PostCSS. + + +## Install + +With [npm](https://npmjs.org/package/postcss-reduce-idents) do: + +``` +npm install postcss-reduce-idents --save +``` + + +## Example + +### Input + +This module will rename custom identifiers in your CSS files; it does so by +converting each name to a index, which is then encoded into a legal identifier. +A legal custom identifier in CSS is case sensitive and must start with a +letter, but can contain digits, hyphens and underscores. There are over 3,000 +possible two character identifiers, and 51 possible single character identifiers +that will be generated. + +```css +@keyframes whiteToBlack { + 0% { + color: #fff + } + to { + color: #000 + } +} + +.one { + animation-name: whiteToBlack +} +``` + +### Output + +```css +@keyframes a { + 0% { + color: #fff + } + to { + color: #000 + } +} + +.one { + animation-name: a +} +``` + +Note that this module does not handle identifiers that are not linked together. +The following example will not be transformed in any way: + +```css +@keyframes fadeOut { + 0% { opacity: 1 } + to { opacity: 0 } +} + +.fadeIn { + animation-name: fadeIn; +} +``` + +It works for `@keyframes`, `@counter-style`, custom `counter` values and grid area definitions. See the +[documentation][idents] for more information, or the [tests](test.js) for more +examples. + + +## Usage + +See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for +examples for your environment. + + +## API + +### reduceIdents([options]) + +#### options + +##### counter + +Type: `boolean` +Default: `true` + +Pass `false` to disable reducing `content`, `counter-reset` and `counter-increment` declarations. + +##### keyframes + +Type: `boolean` +Default: `true` + +Pass `false` to disable reducing `keyframes` rules and `animation` declarations. + +##### counterStyle + +Type: `boolean` +Default: `true` + +Pass `false` to disable reducing `counter-style` rules and `list-style` and `system` declarations. + +##### gridTemplate + +Type: `boolean` +Default: `true` + +Pass `false` to disable reducing `grid-template`, `grid-area` and `grid-template-areas` declarations. + +##### encoder + +Type: `function` +Default: [`lib/encode.js`](https://github.com/ben-eb/postcss-reduce-idents/blob/master/src/lib/encode.js) + +Pass a custom function to encode the identifier with (e.g.: as a way of prefixing them automatically). + +It receives two parameters: + - A `String` with the node value. + - A `Number` identifying the index of the occurrence. + +## 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-reduce-idents/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-reduce-idents/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-reduce-idents/commits?author=ben-eb) | [<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-reduce-idents/commits?author=TrySound) [💻](https://github.com/ben-eb/postcss-reduce-idents/commits?author=TrySound) | [<img src="https://avatars.githubusercontent.com/u/13041?v=3" width="100px;"/><br /><sub>Guillermo Rauch</sub>](http://twitter.com/rauchg)<br />[💻](https://github.com/ben-eb/postcss-reduce-idents/commits?author=rauchg) [📖](https://github.com/ben-eb/postcss-reduce-idents/commits?author=rauchg) [⚠️](https://github.com/ben-eb/postcss-reduce-idents/commits?author=rauchg) | [<img src="https://avatars.githubusercontent.com/u/566536?v=3" width="100px;"/><br /><sub>Sylvain Pollet-Villard</sub>](https://github.com/sylvainpolletvillard)<br />[💻](https://github.com/ben-eb/postcss-reduce-idents/commits?author=sylvainpolletvillard) [📖](https://github.com/ben-eb/postcss-reduce-idents/commits?author=sylvainpolletvillard) [⚠️](https://github.com/ben-eb/postcss-reduce-idents/commits?author=sylvainpolletvillard) | +| :---: | :---: | :---: | :---: | +<!-- ALL-CONTRIBUTORS-LIST:END --> + +This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! + + +## License + +MIT © [Ben Briggs](http://beneb.info) + + +[ci]: https://travis-ci.org/ben-eb/postcss-reduce-idents +[deps]: https://gemnasium.com/ben-eb/postcss-reduce-idents +[idents]: https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident +[npm]: http://badge.fury.io/js/postcss-reduce-idents +[postcss]: https://github.com/postcss/postcss diff --git a/node_modules/postcss-reduce-idents/dist/index.js b/node_modules/postcss-reduce-idents/dist/index.js new file mode 100644 index 00000000..32d03fb4 --- /dev/null +++ b/node_modules/postcss-reduce-idents/dist/index.js @@ -0,0 +1,62 @@ +'use strict'; + +exports.__esModule = true; + +var _postcss = require('postcss'); + +var _postcss2 = _interopRequireDefault(_postcss); + +var _encode = require('./lib/encode'); + +var _encode2 = _interopRequireDefault(_encode); + +var _counter = require('./lib/counter'); + +var _counter2 = _interopRequireDefault(_counter); + +var _counterStyle = require('./lib/counter-style'); + +var _counterStyle2 = _interopRequireDefault(_counterStyle); + +var _keyframes = require('./lib/keyframes'); + +var _keyframes2 = _interopRequireDefault(_keyframes); + +var _gridTemplate = require('./lib/grid-template'); + +var _gridTemplate2 = _interopRequireDefault(_gridTemplate); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = _postcss2.default.plugin('postcss-reduce-idents', function () { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref$counter = _ref.counter, + counter = _ref$counter === undefined ? true : _ref$counter, + _ref$counterStyle = _ref.counterStyle, + counterStyle = _ref$counterStyle === undefined ? true : _ref$counterStyle, + _ref$keyframes = _ref.keyframes, + keyframes = _ref$keyframes === undefined ? true : _ref$keyframes, + _ref$gridTemplate = _ref.gridTemplate, + gridTemplate = _ref$gridTemplate === undefined ? true : _ref$gridTemplate, + _ref$encoder = _ref.encoder, + encoder = _ref$encoder === undefined ? _encode2.default : _ref$encoder; + + var reducers = []; + counter && reducers.push(_counter2.default); + counterStyle && reducers.push(_counterStyle2.default); + keyframes && reducers.push(_keyframes2.default); + gridTemplate && reducers.push(_gridTemplate2.default); + + return function (css) { + css.walk(function (node) { + reducers.forEach(function (reducer) { + return reducer.collect(node, encoder); + }); + }); + + reducers.forEach(function (reducer) { + return reducer.transform(); + }); + }; +}); +module.exports = exports['default'];
\ No newline at end of file diff --git a/node_modules/postcss-reduce-idents/dist/lib/cache.js b/node_modules/postcss-reduce-idents/dist/lib/cache.js new file mode 100644 index 00000000..ccbdcfc6 --- /dev/null +++ b/node_modules/postcss-reduce-idents/dist/lib/cache.js @@ -0,0 +1,15 @@ +"use strict"; + +exports.__esModule = true; + +exports.default = function (value, encoder, cache) { + if (cache[value]) { + return; + } + cache[value] = { + ident: encoder(value, Object.keys(cache).length), + count: 0 + }; +}; + +module.exports = exports["default"];
\ No newline at end of file diff --git a/node_modules/postcss-reduce-idents/dist/lib/counter-style.js b/node_modules/postcss-reduce-idents/dist/lib/counter-style.js new file mode 100644 index 00000000..a1911765 --- /dev/null +++ b/node_modules/postcss-reduce-idents/dist/lib/counter-style.js @@ -0,0 +1,65 @@ +"use strict"; + +exports.__esModule = true; + +var _postcssValueParser = require("postcss-value-parser"); + +var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser); + +var _cache = require("./cache"); + +var _cache2 = _interopRequireDefault(_cache); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var RESERVED_KEYWORDS = ["unset", "initial", "inherit", "none", "inline", "outside", "disc", "circle", "square", "decimal", "cjk-decimal", "decimal-leading-zero", "lower-roman", "upper-roman", "lower-greek", "lower-alpha", "lower-latin", "upper-alpha", "upper-latin", "arabic-indic", "armenian", "bengali", "cambodian", "cjk-earthly-branch", "cjk-heavenly-stem", "cjk-ideographic", "devanagari", "ethiopic-numeric", "georgian", "gujarati", "gurmukhi", "hebrew", "hiragana", "hiragana-iroha", "japanese-formal", "japanese-informal", "kannada", "katakana", "katakana-iroha", "khmer", "korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal", "lao", "lower-armenian", "malayalam", "mongolian", "myanmar", "oriya", "persian", "simp-chinese-formal", "simp-chinese-informal", "tamil", "telugu", "thai", "tibetan", "trad-chinese-formal", "trad-chinese-informal", "upper-armenian", "disclosure-open", "disclosure-close"]; + +var cache = {}; +var atRules = []; +var decls = []; + +exports.default = { + collect: function collect(node, encoder) { + var name = node.name, + prop = node.prop, + type = node.type; + + + if (type === 'atrule' && /counter-style/.test(name) && RESERVED_KEYWORDS.indexOf(node.params) === -1) { + (0, _cache2.default)(node.params, encoder, cache); + atRules.push(node); + } + + if (type === 'decl' && /(list-style|system)/.test(prop)) { + decls.push(node); + } + }, + transform: function transform() { + // Iterate each property and change their names + decls.forEach(function (decl) { + decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) { + if (node.type === 'word' && node.value in cache) { + cache[node.value].count++; + node.value = cache[node.value].ident; + } else if (node.type === 'space') { + node.value = ' '; + } else if (node.type === 'div') { + node.before = node.after = ''; + } + }).toString(); + }); + // Iterate each at rule and change their name if references to them have been found + atRules.forEach(function (rule) { + var cached = cache[rule.params]; + if (cached && cached.count > 0) { + rule.params = cached.ident; + } + }); + + // reset cache after transform + cache = {}; + atRules = []; + decls = []; + } +}; +module.exports = exports["default"];
\ No newline at end of file diff --git a/node_modules/postcss-reduce-idents/dist/lib/counter.js b/node_modules/postcss-reduce-idents/dist/lib/counter.js new file mode 100644 index 00000000..6260efa9 --- /dev/null +++ b/node_modules/postcss-reduce-idents/dist/lib/counter.js @@ -0,0 +1,92 @@ +"use strict"; + +exports.__esModule = true; + +var _postcssValueParser = require("postcss-value-parser"); + +var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser); + +var _cache = require("./cache"); + +var _cache2 = _interopRequireDefault(_cache); + +var _isNum = require("./isNum"); + +var _isNum2 = _interopRequireDefault(_isNum); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var RESERVED_KEYWORDS = ["unset", "initial", "inherit", "none"]; + +var cache = {}; +var declOneCache = []; +var declTwoCache = []; + +exports.default = { + collect: function collect(node, encoder) { + var prop = node.prop, + type = node.type; + + + if (type !== 'decl') { + return; + } + + if (/counter-(reset|increment)/.test(prop)) { + node.value = (0, _postcssValueParser2.default)(node.value).walk(function (child) { + if (child.type === 'word' && !(0, _isNum2.default)(child) && RESERVED_KEYWORDS.indexOf(child.value) === -1) { + (0, _cache2.default)(child.value, encoder, cache); + child.value = cache[child.value].ident; + } + + if (child.type === 'space') { + child.value = ' '; + } + }); + declOneCache.push(node); + } else if (/content/.test(prop)) { + declTwoCache.push(node); + } + }, + transform: function transform() { + declTwoCache.forEach(function (decl) { + decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) { + var type = node.type, + value = node.value; + + if (type === 'function' && (value === 'counter' || value === 'counters')) { + (0, _postcssValueParser.walk)(node.nodes, function (child) { + if (child.type === 'word' && child.value in cache) { + cache[child.value].count++; + child.value = cache[child.value].ident; + } else if (child.type === 'div') { + child.before = child.after = ''; + } + }); + } + if (type === 'space') { + node.value = ' '; + } + return false; + }).toString(); + }); + declOneCache.forEach(function (decl) { + decl.value = decl.value.walk(function (node) { + if (node.type === 'word' && !(0, _isNum2.default)(node)) { + Object.keys(cache).forEach(function (key) { + var cached = cache[key]; + if (cached.ident === node.value && !cached.count) { + node.value = key; + } + }); + } + }).toString(); + }); + + // reset cache after transform + cache = {}; + declOneCache = []; + declTwoCache = []; + } +}; +module.exports = exports["default"];
\ No newline at end of file diff --git a/node_modules/postcss-reduce-idents/dist/lib/encode.js b/node_modules/postcss-reduce-idents/dist/lib/encode.js new file mode 100644 index 00000000..6a4ff481 --- /dev/null +++ b/node_modules/postcss-reduce-idents/dist/lib/encode.js @@ -0,0 +1,22 @@ +'use strict'; + +exports.__esModule = true; +exports.default = encode; +function encode(val, num) { + var base = 52; + var characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + var character = num % base; + var result = characters[character]; + var remainder = Math.floor(num / base); + if (remainder) { + base = 64; + characters = characters + '0123456789-_'; + while (remainder) { + character = remainder % base; + remainder = Math.floor(remainder / base); + result = result + characters[character]; + } + } + return result; +}; +module.exports = exports['default'];
\ No newline at end of file diff --git a/node_modules/postcss-reduce-idents/dist/lib/grid-template.js b/node_modules/postcss-reduce-idents/dist/lib/grid-template.js new file mode 100644 index 00000000..49accbff --- /dev/null +++ b/node_modules/postcss-reduce-idents/dist/lib/grid-template.js @@ -0,0 +1,78 @@ +"use strict"; + +exports.__esModule = true; + +var _postcssValueParser = require("postcss-value-parser"); + +var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser); + +var _cache = require("./cache"); + +var _cache2 = _interopRequireDefault(_cache); + +var _isNum = require("./isNum"); + +var _isNum2 = _interopRequireDefault(_isNum); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var RESERVED_KEYWORDS = ["auto", "span", "inherit", "initial", "unset"]; + +var cache = {}; +var declCache = []; + +exports.default = { + collect: function collect(node, encoder) { + if (node.type !== 'decl') { + return; + } + + if (/(grid-template|grid-template-areas)/.test(node.prop)) { + (0, _postcssValueParser2.default)(node.value).walk(function (child) { + if (child.type === 'string') { + child.value.split(/\s+/).forEach(function (word) { + if (/\.+/.test(word)) { + // reduce empty zones to a single `.` + node.value = node.value.replace(word, "."); + } else if (word && RESERVED_KEYWORDS.indexOf(word) === -1) { + (0, _cache2.default)(word, encoder, cache); + } + }); + } + }); + declCache.push(node); + } else if (node.prop === 'grid-area') { + (0, _postcssValueParser2.default)(node.value).walk(function (child) { + if (child.type === 'word' && RESERVED_KEYWORDS.indexOf(child.value) === -1) { + (0, _cache2.default)(child.value, encoder, cache); + } + }); + declCache.push(node); + } + }, + transform: function transform() { + declCache.forEach(function (decl) { + decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) { + if (/(grid-template|grid-template-areas)/.test(decl.prop)) { + node.value.split(/\s+/).forEach(function (word) { + if (word in cache) { + node.value = node.value.replace(word, cache[word].ident); + } + }); + node.value = node.value.replace(/\s+/g, " "); // merge white-spaces + } + if (decl.prop === 'grid-area' && !(0, _isNum2.default)(node)) { + if (node.value in cache) { + node.value = cache[node.value].ident; + } + } + return false; + }).toString(); + }); + + // reset cache after transform + cache = {}; + declCache = []; + } +}; +module.exports = exports["default"];
\ No newline at end of file diff --git a/node_modules/postcss-reduce-idents/dist/lib/isNum.js b/node_modules/postcss-reduce-idents/dist/lib/isNum.js new file mode 100644 index 00000000..ddb41fad --- /dev/null +++ b/node_modules/postcss-reduce-idents/dist/lib/isNum.js @@ -0,0 +1,11 @@ +"use strict"; + +exports.__esModule = true; +exports.default = isNum; + +var _postcssValueParser = require("postcss-value-parser"); + +function isNum(node) { + return (0, _postcssValueParser.unit)(node.value); +} +module.exports = exports["default"];
\ No newline at end of file diff --git a/node_modules/postcss-reduce-idents/dist/lib/keyframes.js b/node_modules/postcss-reduce-idents/dist/lib/keyframes.js new file mode 100644 index 00000000..1b95a876 --- /dev/null +++ b/node_modules/postcss-reduce-idents/dist/lib/keyframes.js @@ -0,0 +1,65 @@ +"use strict"; + +exports.__esModule = true; + +var _postcssValueParser = require("postcss-value-parser"); + +var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser); + +var _cache = require("./cache"); + +var _cache2 = _interopRequireDefault(_cache); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var RESERVED_KEYWORDS = ["none", "inherit", "initial", "unset"]; + +var cache = {}; +var atRules = []; +var decls = []; + +exports.default = { + collect: function collect(node, encoder) { + var name = node.name, + prop = node.prop, + type = node.type; + + + if (type === 'atrule' && /keyframes/.test(name) && RESERVED_KEYWORDS.indexOf(node.params) === -1) { + (0, _cache2.default)(node.params, encoder, cache); + atRules.push(node); + } + + if (type === 'decl' && /animation/.test(prop)) { + decls.push(node); + } + }, + transform: function transform() { + // Iterate each property and change their names + decls.forEach(function (decl) { + decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) { + if (node.type === 'word' && node.value in cache) { + cache[node.value].count++; + node.value = cache[node.value].ident; + } else if (node.type === 'space') { + node.value = ' '; + } else if (node.type === 'div') { + node.before = node.after = ''; + } + }).toString(); + }); + // Iterate each at rule and change their name if references to them have been found + atRules.forEach(function (rule) { + var cached = cache[rule.params]; + if (cached && cached.count > 0) { + rule.params = cached.ident; + } + }); + + // reset cache after transform + cache = {}; + atRules = []; + decls = []; + } +}; +module.exports = exports["default"];
\ No newline at end of file diff --git a/node_modules/postcss-reduce-idents/package.json b/node_modules/postcss-reduce-idents/package.json new file mode 100644 index 00000000..815ed733 --- /dev/null +++ b/node_modules/postcss-reduce-idents/package.json @@ -0,0 +1,57 @@ +{ + "name": "postcss-reduce-idents", + "version": "2.4.0", + "description": "Reduce custom identifiers with PostCSS.", + "main": "dist/index.js", + "files": [ + "dist", + "LICENSE-MIT" + ], + "scripts": { + "contributorAdd": "all-contributors add", + "contributorGenerate": "all-contributors generate", + "pretest": "eslint src --fix", + "prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/", + "test": "ava src/__tests__/*.js", + "test-012": "ava src/__tests__/*.js" + }, + "keywords": [ + "css", + "postcss", + "postcss-plugin" + ], + "license": "MIT", + "devDependencies": { + "all-contributors-cli": "^3.0.7", + "ava": "^0.17.0", + "babel-cli": "^6.3.17", + "babel-core": "^6.3.26", + "babel-plugin-add-module-exports": "^0.2.1", + "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", + "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" + }, + "homepage": "https://github.com/ben-eb/postcss-reduce-idents", + "author": { + "name": "Ben Briggs", + "email": "beneb.info@gmail.com", + "url": "http://beneb.info" + }, + "repository": "ben-eb/postcss-reduce-idents", + "dependencies": { + "postcss": "^5.0.4", + "postcss-value-parser": "^3.0.2" + }, + "ava": { + "require": "babel-register" + }, + "eslintConfig": { + "extends": "cssnano" + } +} |
