postcss-colormin 5.2.1 → 5.2.2
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 +18 -8
- package/dist/minifyColor.js +2 -12
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -76,22 +76,32 @@ function transform(value, options) {
|
|
|
76
76
|
return parsed.toString();
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
function
|
|
79
|
+
function addPluginDefaults(options, browsers) {
|
|
80
|
+
const defaults = {
|
|
81
|
+
transparent: browsers.some(hasTransparentBug) === false,
|
|
82
|
+
// Does the browser support 4 & 8 character hex notation
|
|
83
|
+
alphaHex: (0, _caniuseApi.isSupported)('css-rrggbbaa', browsers),
|
|
84
|
+
// Does the browser support "transparent" value properly
|
|
85
|
+
name: true
|
|
86
|
+
};
|
|
87
|
+
return { ...defaults,
|
|
88
|
+
...options
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function pluginCreator(config = {}) {
|
|
80
93
|
return {
|
|
81
94
|
postcssPlugin: 'postcss-colormin',
|
|
82
95
|
|
|
83
96
|
prepare(result) {
|
|
84
|
-
const
|
|
97
|
+
const resultOptions = result.opts || {};
|
|
85
98
|
const browsers = (0, _browserslist.default)(null, {
|
|
86
|
-
stats:
|
|
99
|
+
stats: resultOptions.stats,
|
|
87
100
|
path: __dirname,
|
|
88
|
-
env:
|
|
101
|
+
env: resultOptions.env
|
|
89
102
|
});
|
|
90
|
-
const options = {
|
|
91
|
-
supportsTransparent: browsers.some(hasTransparentBug) === false,
|
|
92
|
-
supportsAlphaHex: (0, _caniuseApi.isSupported)('css-rrggbbaa', browsers)
|
|
93
|
-
};
|
|
94
103
|
const cache = {};
|
|
104
|
+
const options = addPluginDefaults(config, browsers);
|
|
95
105
|
return {
|
|
96
106
|
OnceExit(css) {
|
|
97
107
|
css.walkDecls(decl => {
|
package/dist/minifyColor.js
CHANGED
|
@@ -18,25 +18,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
* Performs color value minification
|
|
19
19
|
*
|
|
20
20
|
* @param {string} input - CSS value
|
|
21
|
-
* @param {boolean} options
|
|
22
|
-
* @param {boolean} options.supportsTransparent – Does the browser support "transparent" value properly
|
|
21
|
+
* @param {boolean} options - object with colord.minify() options
|
|
23
22
|
*/
|
|
24
23
|
|
|
25
24
|
function minifyColor(input, options = {}) {
|
|
26
|
-
const settings = {
|
|
27
|
-
supportsAlphaHex: false,
|
|
28
|
-
supportsTransparent: true,
|
|
29
|
-
...options
|
|
30
|
-
};
|
|
31
25
|
const instance = (0, _colord.colord)(input);
|
|
32
26
|
|
|
33
27
|
if (instance.isValid()) {
|
|
34
28
|
// Try to shorten the string if it is a valid CSS color value
|
|
35
|
-
const minified = instance.minify(
|
|
36
|
-
alphaHex: settings.supportsAlphaHex,
|
|
37
|
-
transparent: settings.supportsTransparent,
|
|
38
|
-
name: true
|
|
39
|
-
}); // Fall back to the original input if it's smaller or has equal length
|
|
29
|
+
const minified = instance.minify(options); // Fall back to the original input if it's smaller or has equal length
|
|
40
30
|
|
|
41
31
|
return minified.length < input.length ? minified : input.toLowerCase();
|
|
42
32
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-colormin",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"description": "Minify colors in your CSS files with PostCSS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prebuild": "rimraf dist",
|
|
12
|
-
"build": "
|
|
12
|
+
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
|
|
13
13
|
"prepare": "yarn build"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"browserslist": "^4.16.6",
|
|
34
34
|
"caniuse-api": "^3.0.0",
|
|
35
35
|
"colord": "^2.9.1",
|
|
36
|
-
"postcss-value-parser": "^4.
|
|
36
|
+
"postcss-value-parser": "^4.2.0"
|
|
37
37
|
},
|
|
38
38
|
"bugs": {
|
|
39
39
|
"url": "https://github.com/cssnano/cssnano/issues"
|
|
@@ -46,6 +46,5 @@
|
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"postcss": "^8.2.15"
|
|
49
|
-
}
|
|
50
|
-
"gitHead": "2d84646671c7075f8dae35de310351aac3436bc0"
|
|
49
|
+
}
|
|
51
50
|
}
|