postcss-minify-params 5.1.0 → 5.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/src/index.js +16 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-minify-params",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.3",
|
|
4
4
|
"description": "Minify at-rule params with PostCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postcss",
|
|
@@ -37,6 +37,5 @@
|
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"postcss": "^8.2.15"
|
|
40
|
-
}
|
|
41
|
-
"readme": "# postcss-minify-params [![Build Status][ci-img]][ci]\n\n> Minify at-rule params with PostCSS.\n\n```css\n@media only screen and ( min-width: 400px, min-height: 500px ) {\n h2{\n color:blue\n }\n}\n```\n\n```css\n@media only screen and (min-width:400px,min-height:500px) {\n h2{\n color:blue\n }\n}\n```\n\n## Usage\n\n```js\npostcss([ require('postcss-minify-params') ])\n```\n\nSee [PostCSS] docs for examples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nMIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)\n\n[PostCSS]: https://github.com/postcss/postcss\n[ci-img]: https://travis-ci.org/cssnano/postcss-minify-params.svg\n[ci]: https://travis-ci.org/cssnano/postcss-minify-params\n"
|
|
40
|
+
}
|
|
42
41
|
}
|
package/src/index.js
CHANGED
|
@@ -69,11 +69,21 @@ function transform(legacy, rule) {
|
|
|
69
69
|
const params = valueParser(rule.params);
|
|
70
70
|
|
|
71
71
|
params.walk((node, index) => {
|
|
72
|
-
if (node.type === 'div'
|
|
72
|
+
if (node.type === 'div') {
|
|
73
73
|
node.before = node.after = '';
|
|
74
|
-
|
|
74
|
+
} else if (node.type === 'function') {
|
|
75
|
+
node.before = '';
|
|
76
|
+
if (
|
|
77
|
+
node.nodes[0] &&
|
|
78
|
+
node.nodes[0].type === 'word' &&
|
|
79
|
+
node.nodes[0].value.startsWith('--') &&
|
|
80
|
+
node.nodes[2] === undefined
|
|
81
|
+
) {
|
|
82
|
+
node.after = ' ';
|
|
83
|
+
} else {
|
|
84
|
+
node.after = '';
|
|
85
|
+
}
|
|
75
86
|
if (
|
|
76
|
-
node.type === 'function' &&
|
|
77
87
|
node.nodes[4] &&
|
|
78
88
|
node.nodes[0].value.toLowerCase().indexOf('-aspect-ratio') === 3
|
|
79
89
|
) {
|
|
@@ -120,13 +130,7 @@ function transform(legacy, rule) {
|
|
|
120
130
|
}
|
|
121
131
|
}
|
|
122
132
|
|
|
123
|
-
|
|
124
|
-
* @param {string} browser
|
|
125
|
-
* @return {boolean}
|
|
126
|
-
*/
|
|
127
|
-
function hasAllBug(browser) {
|
|
128
|
-
return ['ie 10', 'ie 11'].includes(browser);
|
|
129
|
-
}
|
|
133
|
+
const allBugBrowers = new Set(['ie 10', 'ie 11']);
|
|
130
134
|
|
|
131
135
|
/**
|
|
132
136
|
* @type {import('postcss').PluginCreator<browserslist.Options>}
|
|
@@ -140,11 +144,12 @@ function pluginCreator(options = {}) {
|
|
|
140
144
|
env: options.env,
|
|
141
145
|
});
|
|
142
146
|
|
|
147
|
+
const hasAllBug = browsers.some((browser) => allBugBrowers.has(browser));
|
|
143
148
|
return {
|
|
144
149
|
postcssPlugin: 'postcss-minify-params',
|
|
145
150
|
|
|
146
151
|
OnceExit(css) {
|
|
147
|
-
css.walkAtRules(transform
|
|
152
|
+
css.walkAtRules((rule) => transform(hasAllBug, rule));
|
|
148
153
|
},
|
|
149
154
|
};
|
|
150
155
|
}
|