postcss-discard-unused 5.0.1 → 5.0.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 +8 -14
- package/package.json +7 -8
- package/CHANGELOG.md +0 -63
package/dist/index.js
CHANGED
|
@@ -13,12 +13,6 @@ const atrule = 'atrule';
|
|
|
13
13
|
const decl = 'decl';
|
|
14
14
|
const rule = 'rule';
|
|
15
15
|
|
|
16
|
-
function uniqs(items) {
|
|
17
|
-
return items.filter(function (item, i) {
|
|
18
|
-
return i === items.indexOf(item);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
16
|
function addValues(cache, {
|
|
23
17
|
value
|
|
24
18
|
}, comma, space) {
|
|
@@ -29,9 +23,9 @@ function filterAtRule({
|
|
|
29
23
|
atRules,
|
|
30
24
|
values
|
|
31
25
|
}) {
|
|
32
|
-
values =
|
|
26
|
+
values = new Set(values);
|
|
33
27
|
atRules.forEach(node => {
|
|
34
|
-
const hasAtRule = values.
|
|
28
|
+
const hasAtRule = values.has(node.params);
|
|
35
29
|
|
|
36
30
|
if (!hasAtRule) {
|
|
37
31
|
node.remove();
|
|
@@ -43,7 +37,7 @@ function filterNamespace({
|
|
|
43
37
|
atRules,
|
|
44
38
|
rules
|
|
45
39
|
}) {
|
|
46
|
-
rules =
|
|
40
|
+
rules = new Set(rules);
|
|
47
41
|
atRules.forEach(atRule => {
|
|
48
42
|
const {
|
|
49
43
|
0: param,
|
|
@@ -54,7 +48,7 @@ function filterNamespace({
|
|
|
54
48
|
return;
|
|
55
49
|
}
|
|
56
50
|
|
|
57
|
-
const hasRule = rules.
|
|
51
|
+
const hasRule = rules.has(param) || rules.has('*');
|
|
58
52
|
|
|
59
53
|
if (!hasRule) {
|
|
60
54
|
atRule.remove();
|
|
@@ -63,7 +57,7 @@ function filterNamespace({
|
|
|
63
57
|
}
|
|
64
58
|
|
|
65
59
|
function hasFont(fontFamily, cache, comma) {
|
|
66
|
-
return comma(fontFamily).some(font => cache.some(c =>
|
|
60
|
+
return comma(fontFamily).some(font => cache.some(c => c.includes(font)));
|
|
67
61
|
} // fonts have slightly different logic
|
|
68
62
|
|
|
69
63
|
|
|
@@ -71,7 +65,7 @@ function filterFont({
|
|
|
71
65
|
atRules,
|
|
72
66
|
values
|
|
73
67
|
}, comma) {
|
|
74
|
-
values =
|
|
68
|
+
values = [...new Set(values)];
|
|
75
69
|
atRules.forEach(r => {
|
|
76
70
|
const families = r.nodes.filter(({
|
|
77
71
|
prop
|
|
@@ -137,8 +131,8 @@ function pluginCreator(opts) {
|
|
|
137
131
|
name
|
|
138
132
|
} = node;
|
|
139
133
|
|
|
140
|
-
if (type === rule && namespace &&
|
|
141
|
-
if (
|
|
134
|
+
if (type === rule && namespace && selector.includes('|')) {
|
|
135
|
+
if (selector.includes('[')) {
|
|
142
136
|
// Attribute selector, so we should parse further.
|
|
143
137
|
(0, _postcssSelectorParser.default)(ast => {
|
|
144
138
|
ast.walkAttributes(({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-discard-unused",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Discard unused counter styles, keyframes and fonts.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -8,11 +8,6 @@
|
|
|
8
8
|
"LICENSE-MIT",
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"prebuild": "del-cli dist",
|
|
13
|
-
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
|
|
14
|
-
"prepublish": "yarn build"
|
|
15
|
-
},
|
|
16
11
|
"keywords": [
|
|
17
12
|
"css",
|
|
18
13
|
"minify",
|
|
@@ -44,5 +39,9 @@
|
|
|
44
39
|
"peerDependencies": {
|
|
45
40
|
"postcss": "^8.2.15"
|
|
46
41
|
},
|
|
47
|
-
"
|
|
48
|
-
|
|
42
|
+
"scripts": {
|
|
43
|
+
"prebuild": "rimraf dist",
|
|
44
|
+
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\""
|
|
45
|
+
},
|
|
46
|
+
"readme": "# [postcss][postcss]-discard-unused\n\n> Discard unused counter styles, keyframes and fonts.\n\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-discard-unused) do:\n\n```\nnpm install postcss-discard-unused --save\n```\n\n\n## Example\n\nThis module will discard unused at rules in your CSS file, if it cannot find\nany selectors that make use of them. It works on `@counter-style`, `@keyframes`\nand `@font-face`.\n\n### Input\n\n```css\n@counter-style custom {\n system: extends decimal;\n suffix: \"> \"\n}\n\n@counter-style custom2 {\n system: extends decimal;\n suffix: \"| \"\n}\n\na {\n list-style: custom\n}\n```\n\n### Output\n\n```css\n@counter-style custom {\n system: extends decimal;\n suffix: \"> \"\n}\n\na {\n list-style: custom\n}\n```\n\nNote that this plugin is not responsible for normalising font families, as it\nmakes the assumption that you will write your font names consistently, such that\nit considers these two declarations differently:\n\n```css\nh1 {\n font-family: \"Helvetica Neue\"\n}\n\nh2 {\n font-family: Helvetica Neue\n}\n```\n\nHowever, you can mitigate this by including [postcss-minify-font-values][mfv]\n*before* this plugin, which will take care of normalising quotes, and\ndeduplicating. For more examples, see the [tests](src/__tests__/index.js).\n\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n\n## API\n\n### discardUnused([options])\n\n#### options\n\n##### fontFace\n\nType: `boolean` \nDefault: `true`\n\nPass `false` to disable discarding unused font face rules.\n\n##### counterStyle\n\nType: `boolean` \nDefault: `true`\n\nPass `false` to disable discarding unused counter style rules.\n\n##### keyframes\n\nType: `boolean` \nDefault: `true`\n\nPass `false` to disable discarding unused keyframe rules.\n\n##### namespace\n\nType: `boolean` \nDefault: `true`\n\nPass `false` to disable discarding unused namespace rules.\n\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n\n[postcss]: https://github.com/postcss/postcss\n[mfv]: https://github.com/trysound/postcss-minify-font-values\n"
|
|
47
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,63 +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.1](https://github.com/cssnano/cssnano/compare/postcss-discard-unused@5.0.0...postcss-discard-unused@5.0.1) (2021-05-19)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package postcss-discard-unused
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [5.0.0](https://github.com/cssnano/cssnano/compare/postcss-discard-unused@5.0.0-rc.2...postcss-discard-unused@5.0.0) (2021-04-06)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package postcss-discard-unused
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-discard-unused@5.0.0-rc.1...postcss-discard-unused@5.0.0-rc.2) (2021-03-15)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package postcss-discard-unused
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-discard-unused@5.0.0-rc.0...postcss-discard-unused@5.0.0-rc.1) (2021-03-04)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package postcss-discard-unused
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# 5.0.0-rc.0 (2021-02-19)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### chore
|
|
42
|
-
|
|
43
|
-
* minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
### Features
|
|
47
|
-
|
|
48
|
-
* migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
### BREAKING CHANGES
|
|
52
|
-
|
|
53
|
-
* minimum supported `postcss` version is `8.2.1`
|
|
54
|
-
* minimum require version of node is 10.13
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## 4.1.1 (2018-09-24)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
### Bug Fixes
|
|
62
|
-
|
|
63
|
-
* **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)
|