postcss-minify-params 4.0.2 → 5.0.0
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/CHANGELOG.md +70 -0
- package/dist/index.js +79 -88
- package/package.json +16 -12
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [5.0.0](https://github.com/cssnano/cssnano/compare/postcss-minify-params@5.0.0-rc.2...postcss-minify-params@5.0.0) (2021-04-06)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package postcss-minify-params
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-minify-params@5.0.0-rc.1...postcss-minify-params@5.0.0-rc.2) (2021-03-15)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package postcss-minify-params
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-minify-params@5.0.0-rc.0...postcss-minify-params@5.0.0-rc.1) (2021-03-04)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package postcss-minify-params
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# 5.0.0-rc.0 (2021-02-19)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### chore
|
|
34
|
+
|
|
35
|
+
* minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
* migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### BREAKING CHANGES
|
|
44
|
+
|
|
45
|
+
* minimum supported `postcss` version is `8.2.1`
|
|
46
|
+
* minimum require version of node is 10.13
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## 4.1.9 (2019-02-12)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Bug Fixes
|
|
54
|
+
|
|
55
|
+
* do not mangle `[@page](https://github.com/page) :first` rules ([#678](https://github.com/cssnano/cssnano/issues/678)) ([69aab0b](https://github.com/cssnano/cssnano/commit/69aab0b527198979e2232a57554cf888ad868231))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Performance Improvements
|
|
59
|
+
|
|
60
|
+
* **postcss-minify-params:** increase perf ([e06a24e](https://github.com/cssnano/cssnano/commit/e06a24e44aae8935290b7bc05d9da51b99367d2b))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## 4.1.1 (2018-09-24)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Bug Fixes
|
|
68
|
+
|
|
69
|
+
* add `browserslist` to dependencies for `postcss-minify-params` ([#594](https://github.com/cssnano/cssnano/issues/594)) ([9d40806](https://github.com/cssnano/cssnano/commit/9d40806151026dcd2272dc22a76009b27224d512))
|
|
70
|
+
* **postcss-merge-longhand:** not mangle border output ([#555](https://github.com/cssnano/cssnano/issues/555)) ([9a70605](https://github.com/cssnano/cssnano/commit/9a706050b621e7795a9bf74eb7110b5c81804ffe)), closes [#553](https://github.com/cssnano/cssnano/issues/553) [#554](https://github.com/cssnano/cssnano/issues/554)
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.default = void 0;
|
|
6
7
|
|
|
7
|
-
var _browserslist = require(
|
|
8
|
+
var _browserslist = _interopRequireDefault(require("browserslist"));
|
|
8
9
|
|
|
9
|
-
var
|
|
10
|
+
var _postcssValueParser = _interopRequireWildcard(require("postcss-value-parser"));
|
|
10
11
|
|
|
11
|
-
var
|
|
12
|
+
var _alphanumSort = _interopRequireDefault(require("alphanum-sort"));
|
|
12
13
|
|
|
13
|
-
var
|
|
14
|
+
var _uniqs = _interopRequireDefault(require("uniqs"));
|
|
14
15
|
|
|
15
|
-
var
|
|
16
|
+
var _cssnanoUtils = require("cssnano-utils");
|
|
16
17
|
|
|
17
|
-
var
|
|
18
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
18
19
|
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
var _alphanumSort2 = _interopRequireDefault(_alphanumSort);
|
|
22
|
-
|
|
23
|
-
var _uniqs = require('uniqs');
|
|
24
|
-
|
|
25
|
-
var _uniqs2 = _interopRequireDefault(_uniqs);
|
|
26
|
-
|
|
27
|
-
var _cssnanoUtilGetArguments = require('cssnano-util-get-arguments');
|
|
28
|
-
|
|
29
|
-
var _cssnanoUtilGetArguments2 = _interopRequireDefault(_cssnanoUtilGetArguments);
|
|
20
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
30
21
|
|
|
31
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
23
|
|
|
@@ -34,93 +25,93 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
34
25
|
* Return the greatest common divisor
|
|
35
26
|
* of two numbers.
|
|
36
27
|
*/
|
|
37
|
-
|
|
38
28
|
function gcd(a, b) {
|
|
39
|
-
|
|
29
|
+
return b ? gcd(b, a % b) : a;
|
|
40
30
|
}
|
|
41
31
|
|
|
42
32
|
function aspectRatio(a, b) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return [a / divisor, b / divisor];
|
|
33
|
+
const divisor = gcd(a, b);
|
|
34
|
+
return [a / divisor, b / divisor];
|
|
46
35
|
}
|
|
47
36
|
|
|
48
37
|
function split(args) {
|
|
49
|
-
|
|
38
|
+
return args.map(arg => (0, _postcssValueParser.stringify)(arg)).join('');
|
|
50
39
|
}
|
|
51
40
|
|
|
52
41
|
function removeNode(node) {
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
node.value = '';
|
|
43
|
+
node.type = 'word';
|
|
55
44
|
}
|
|
56
45
|
|
|
57
46
|
function transform(legacy, rule) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (!legacy || nextWord) {
|
|
86
|
-
removeNode(node);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (nextWord && nextWord.value.toLowerCase() === 'and') {
|
|
90
|
-
const nextSpace = params.nodes[index + 1];
|
|
91
|
-
const secondSpace = params.nodes[index + 3];
|
|
92
|
-
|
|
93
|
-
removeNode(nextWord);
|
|
94
|
-
removeNode(nextSpace);
|
|
95
|
-
removeNode(secondSpace);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
47
|
+
const ruleName = rule.name.toLowerCase(); // We should re-arrange parameters only for `@media` and `@supports` at-rules
|
|
48
|
+
|
|
49
|
+
if (!rule.params || !['media', 'supports'].includes(ruleName)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const params = (0, _postcssValueParser.default)(rule.params);
|
|
54
|
+
params.walk((node, index) => {
|
|
55
|
+
if (node.type === 'div' || node.type === 'function') {
|
|
56
|
+
node.before = node.after = '';
|
|
57
|
+
|
|
58
|
+
if (node.type === 'function' && node.nodes[4] && node.nodes[0].value.toLowerCase().indexOf('-aspect-ratio') === 3) {
|
|
59
|
+
const [a, b] = aspectRatio(node.nodes[2].value, node.nodes[4].value);
|
|
60
|
+
node.nodes[2].value = a;
|
|
61
|
+
node.nodes[4].value = b;
|
|
62
|
+
}
|
|
63
|
+
} else if (node.type === 'space') {
|
|
64
|
+
node.value = ' ';
|
|
65
|
+
} else {
|
|
66
|
+
const prevWord = params.nodes[index - 2];
|
|
67
|
+
|
|
68
|
+
if (node.value.toLowerCase() === 'all' && rule.name.toLowerCase() === 'media' && !prevWord) {
|
|
69
|
+
const nextWord = params.nodes[index + 2];
|
|
70
|
+
|
|
71
|
+
if (!legacy || nextWord) {
|
|
72
|
+
removeNode(node);
|
|
98
73
|
}
|
|
99
|
-
}, true);
|
|
100
|
-
|
|
101
|
-
rule.params = (0, _alphanumSort2.default)((0, _uniqs2.default)((0, _cssnanoUtilGetArguments2.default)(params).map(split)), {
|
|
102
|
-
insensitive: true
|
|
103
|
-
}).join();
|
|
104
74
|
|
|
105
|
-
|
|
106
|
-
|
|
75
|
+
if (nextWord && nextWord.value.toLowerCase() === 'and') {
|
|
76
|
+
const nextSpace = params.nodes[index + 1];
|
|
77
|
+
const secondSpace = params.nodes[index + 3];
|
|
78
|
+
removeNode(nextWord);
|
|
79
|
+
removeNode(nextSpace);
|
|
80
|
+
removeNode(secondSpace);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
107
83
|
}
|
|
84
|
+
}, true);
|
|
85
|
+
rule.params = (0, _alphanumSort.default)((0, _uniqs.default)((0, _cssnanoUtils.getArguments)(params).map(split)), {
|
|
86
|
+
insensitive: true
|
|
87
|
+
}).join();
|
|
88
|
+
|
|
89
|
+
if (!rule.params.length) {
|
|
90
|
+
rule.raws.afterName = '';
|
|
91
|
+
}
|
|
108
92
|
}
|
|
109
93
|
|
|
110
94
|
function hasAllBug(browser) {
|
|
111
|
-
|
|
95
|
+
return ~['ie 10', 'ie 11'].indexOf(browser);
|
|
112
96
|
}
|
|
113
97
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
98
|
+
function pluginCreator(options = {}) {
|
|
99
|
+
const browsers = (0, _browserslist.default)(null, {
|
|
100
|
+
stats: options.stats,
|
|
101
|
+
path: __dirname,
|
|
102
|
+
env: options.env
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
postcssPlugin: 'postcss-minify-params',
|
|
106
|
+
|
|
107
|
+
OnceExit(css) {
|
|
108
|
+
css.walkAtRules(transform.bind(null, browsers.some(hasAllBug)));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
pluginCreator.postcss = true;
|
|
115
|
+
var _default = pluginCreator;
|
|
116
|
+
exports.default = _default;
|
|
117
|
+
module.exports = exports.default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-minify-params",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Minify at-rule params with PostCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postcss",
|
|
@@ -22,21 +22,25 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/cssnano/cssnano",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"alphanum-sort": "^1.0.
|
|
26
|
-
"browserslist": "^4.
|
|
27
|
-
"cssnano-
|
|
28
|
-
"postcss": "^
|
|
29
|
-
"postcss-value-parser": "^3.0.0",
|
|
25
|
+
"alphanum-sort": "^1.0.2",
|
|
26
|
+
"browserslist": "^4.16.0",
|
|
27
|
+
"cssnano-utils": "^2.0.0",
|
|
28
|
+
"postcss-value-parser": "^4.1.0",
|
|
30
29
|
"uniqs": "^2.0.0"
|
|
31
30
|
},
|
|
32
31
|
"scripts": {
|
|
33
|
-
"
|
|
32
|
+
"prebuild": "del-cli dist",
|
|
33
|
+
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
|
|
34
|
+
"prepublish": "yarn build"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": "^10 || ^12 || >=14.0"
|
|
34
38
|
},
|
|
35
39
|
"devDependencies": {
|
|
36
|
-
"
|
|
37
|
-
"cross-env": "^5.0.0"
|
|
40
|
+
"postcss": "^8.2.1"
|
|
38
41
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
}
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"postcss": "^8.2.1"
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "0e2c3bf5835bafcdc8783bef66f730a24194c8f3"
|
|
42
46
|
}
|