postcss-minify-gradients 5.0.0 → 5.0.4
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/dist/index.js +4 -4
- package/dist/isColorStop.js +47 -0
- package/package.json +12 -13
- package/CHANGELOG.md +0 -69
package/dist/index.js
CHANGED
|
@@ -9,13 +9,13 @@ var _postcssValueParser = _interopRequireWildcard(require("postcss-value-parser"
|
|
|
9
9
|
|
|
10
10
|
var _cssnanoUtils = require("cssnano-utils");
|
|
11
11
|
|
|
12
|
-
var _isColorStop = _interopRequireDefault(require("
|
|
12
|
+
var _isColorStop = _interopRequireDefault(require("./isColorStop.js"));
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
17
|
|
|
18
|
-
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; }
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
19
19
|
|
|
20
20
|
const angles = {
|
|
21
21
|
top: '0deg',
|
|
@@ -62,7 +62,7 @@ function optimise(decl) {
|
|
|
62
62
|
|
|
63
63
|
let lastStop = null;
|
|
64
64
|
args.forEach((arg, index) => {
|
|
65
|
-
if (
|
|
65
|
+
if (arg.length !== 3) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = isColorStop;
|
|
7
|
+
|
|
8
|
+
var _postcssValueParser = require("postcss-value-parser");
|
|
9
|
+
|
|
10
|
+
var _colord = require("colord");
|
|
11
|
+
|
|
12
|
+
var _names = _interopRequireDefault(require("colord/plugins/names"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
(0, _colord.extend)([_names.default]);
|
|
17
|
+
/* Code derived from https://github.com/pigcan/is-color-stop */
|
|
18
|
+
|
|
19
|
+
const lengthArray = ['PX', 'IN', 'CM', 'MM', 'EM', 'REM', 'POINTS', 'PC', 'EX', 'CH', 'VW', 'VH', 'VMIN', 'VMAX', '%'];
|
|
20
|
+
|
|
21
|
+
function isCSSLengthUnit(input) {
|
|
22
|
+
return lengthArray.includes(input.toUpperCase());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isStop(str) {
|
|
26
|
+
let stop = !str;
|
|
27
|
+
|
|
28
|
+
if (!stop) {
|
|
29
|
+
const node = (0, _postcssValueParser.unit)(str);
|
|
30
|
+
|
|
31
|
+
if (node) {
|
|
32
|
+
if (node.number === 0 || !isNaN(node.number) && isCSSLengthUnit(node.unit)) {
|
|
33
|
+
stop = true;
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
stop = /^calc\(\S+\)$/g.test(str);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return stop;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isColorStop(color, stop) {
|
|
44
|
+
return (0, _colord.colord)(color).isValid() && isStop(stop);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = exports.default;
|
package/package.json
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-minify-gradients",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "Minify gradient parameters with PostCSS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"prebuild": "del-cli dist",
|
|
8
|
-
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
|
|
9
|
-
"prepublish": "yarn build"
|
|
10
|
-
},
|
|
11
6
|
"files": [
|
|
12
7
|
"LICENSE-MIT",
|
|
13
8
|
"dist"
|
|
@@ -26,9 +21,9 @@
|
|
|
26
21
|
},
|
|
27
22
|
"repository": "cssnano/cssnano",
|
|
28
23
|
"dependencies": {
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"postcss-value-parser": "^4.
|
|
24
|
+
"colord": "^2.9.1",
|
|
25
|
+
"cssnano-utils": "^3.0.0",
|
|
26
|
+
"postcss-value-parser": "^4.2.0"
|
|
32
27
|
},
|
|
33
28
|
"bugs": {
|
|
34
29
|
"url": "https://github.com/cssnano/cssnano/issues"
|
|
@@ -37,10 +32,14 @@
|
|
|
37
32
|
"node": "^10 || ^12 || >=14.0"
|
|
38
33
|
},
|
|
39
34
|
"devDependencies": {
|
|
40
|
-
"postcss": "^8.2.
|
|
35
|
+
"postcss": "^8.2.15"
|
|
41
36
|
},
|
|
42
37
|
"peerDependencies": {
|
|
43
|
-
"postcss": "^8.2.
|
|
38
|
+
"postcss": "^8.2.15"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"prebuild": "rimraf dist",
|
|
42
|
+
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\""
|
|
44
43
|
},
|
|
45
|
-
"
|
|
46
|
-
}
|
|
44
|
+
"readme": "# [postcss][postcss]-minify-gradients\n\n> Minify gradient parameters with PostCSS.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-minify-gradients) do:\n\n```\nnpm install postcss-minify-gradients\n```\n\n\n## Example\n\nWhere possible, this module will minify gradient parameters. It can convert\nlinear gradient directional syntax to angles, remove the unnecessary `0%` and\n`100%` start and end values, and minimise color stops that use the same length\nvalues (the browser will adjust the value automatically).\n\n### Input\n\n```css\nh1 {\n background: linear-gradient(to bottom, #ffe500 0%, #ffe500 50%, #121 50%, #121 100%)\n}\n```\n\n### Output\n\n```css\nh1 {\n background: linear-gradient(180deg, #ffe500, #ffe500 50%, #121 0, #121)\n}\n```\n\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n"
|
|
45
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
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-gradients@5.0.0-rc.2...postcss-minify-gradients@5.0.0) (2021-04-06)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package postcss-minify-gradients
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-minify-gradients@5.0.0-rc.1...postcss-minify-gradients@5.0.0-rc.2) (2021-03-15)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package postcss-minify-gradients
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-minify-gradients@5.0.0-rc.0...postcss-minify-gradients@5.0.0-rc.1) (2021-03-04)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package postcss-minify-gradients
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# 5.0.0-rc.0 (2021-02-19)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### Bug Fixes
|
|
34
|
-
|
|
35
|
-
* **postcss-minify-gradients:** don't break gradients with `var` and `env` functions ([#735](https://github.com/cssnano/cssnano/issues/735)) ([7fabd9d](https://github.com/cssnano/cssnano/commit/7fabd9d03c81142c5854d0c0a50bee15ed86c219))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### chore
|
|
39
|
-
|
|
40
|
-
* minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### Features
|
|
44
|
-
|
|
45
|
-
* migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### BREAKING CHANGES
|
|
49
|
-
|
|
50
|
-
* minimum supported `postcss` version is `8.2.1`
|
|
51
|
-
* minimum require version of node is 10.13
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## 4.1.9 (2019-02-12)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
### Bug Fixes
|
|
59
|
-
|
|
60
|
-
* **postcss-minify-gradients:** handle uppercase ([#706](https://github.com/cssnano/cssnano/issues/706)) ([acd5d0e](https://github.com/cssnano/cssnano/commit/acd5d0eb59e76fe62b70faad89d6ee0f76f798ef))
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## 4.1.1 (2018-09-24)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
### Bug Fixes
|
|
68
|
-
|
|
69
|
-
* **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)
|