postcss-discard-comments 1.2.0 → 1.2.1
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 +4 -0
- package/index.js +35 -38
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -27,52 +27,49 @@ module.exports = postcss.plugin('postcss-discard-comments', function (options) {
|
|
|
27
27
|
return space(b).join(' ');
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
css.
|
|
31
|
-
if (remover.canRemove(
|
|
32
|
-
|
|
30
|
+
css.eachInside(function (node) {
|
|
31
|
+
if (node.type === 'comment' && remover.canRemove(node.text)) {
|
|
32
|
+
return node.removeSelf();
|
|
33
33
|
}
|
|
34
|
-
});
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (decl._value && decl._value.raw) {
|
|
39
|
-
var replaced = replaceComments(decl._value.raw);
|
|
40
|
-
decl._value.raw = decl._value.value = decl.value = replaced;
|
|
41
|
-
}
|
|
42
|
-
if (decl._important) {
|
|
43
|
-
decl._important = replaceComments(decl._important);
|
|
44
|
-
var b = balanced.matches({
|
|
45
|
-
source: decl._important,
|
|
46
|
-
open: '/*',
|
|
47
|
-
close: '*/'
|
|
48
|
-
});
|
|
49
|
-
decl._important = b.length ? decl._important : '!important';
|
|
35
|
+
if (node.between) {
|
|
36
|
+
node.between = replaceComments(node.between);
|
|
50
37
|
}
|
|
51
|
-
});
|
|
52
38
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
if (node.type === 'decl') {
|
|
40
|
+
if (node._value && node._value.raw) {
|
|
41
|
+
var replaced = replaceComments(node._value.raw);
|
|
42
|
+
node._value.raw = node._value.value = node.value = replaced;
|
|
43
|
+
}
|
|
44
|
+
if (node._important) {
|
|
45
|
+
node._important = replaceComments(node._important);
|
|
46
|
+
var b = balanced.matches({
|
|
47
|
+
source: node._important,
|
|
48
|
+
open: '/*',
|
|
49
|
+
close: '*/'
|
|
50
|
+
});
|
|
51
|
+
node._important = b.length ? node._important : '!important';
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
56
54
|
}
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
|
|
56
|
+
if (node.type === 'rule' && node._selector && node._selector.raw) {
|
|
57
|
+
node._selector.raw = replaceComments(node._selector.raw);
|
|
58
|
+
return;
|
|
59
59
|
}
|
|
60
|
-
});
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
if (node.type === 'atrule') {
|
|
62
|
+
if (node.afterName) {
|
|
63
|
+
var commentsReplaced = replaceComments(node.afterName);
|
|
64
|
+
if (!commentsReplaced.length) {
|
|
65
|
+
node.afterName = commentsReplaced + ' ';
|
|
66
|
+
} else {
|
|
67
|
+
node.afterName = ' ' + commentsReplaced + ' ';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (node._params && node._params.raw) {
|
|
71
|
+
node._params.raw = replaceComments(node._params.raw);
|
|
69
72
|
}
|
|
70
|
-
}
|
|
71
|
-
if (rule._params && rule._params.raw) {
|
|
72
|
-
rule._params.raw = replaceComments(rule._params.raw);
|
|
73
|
-
}
|
|
74
|
-
if (rule.between) {
|
|
75
|
-
rule.between = replaceComments(rule.between);
|
|
76
73
|
}
|
|
77
74
|
});
|
|
78
75
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-discard-comments",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Discard comments in your CSS files with PostCSS.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"lint": "jshint index.js lib/commentRemover.js --reporter node_modules/jshint-stylish/stylish.js",
|
|
8
7
|
"test": "tape test.js | tap-spec"
|
|
9
8
|
},
|
|
10
9
|
"keywords": [
|
|
@@ -15,10 +14,8 @@
|
|
|
15
14
|
],
|
|
16
15
|
"license": "MIT",
|
|
17
16
|
"devDependencies": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"tap-spec": "^2.2.2",
|
|
21
|
-
"tape": "^3.5.0"
|
|
17
|
+
"tap-spec": "^4.0.2",
|
|
18
|
+
"tape": "^4.1.0"
|
|
22
19
|
},
|
|
23
20
|
"homepage": "https://github.com/ben-eb/postcss-discard-comments",
|
|
24
21
|
"author": {
|
|
@@ -32,6 +29,6 @@
|
|
|
32
29
|
},
|
|
33
30
|
"dependencies": {
|
|
34
31
|
"node-balanced": "0.0.14",
|
|
35
|
-
"postcss": "^4.1.
|
|
32
|
+
"postcss": "^4.1.16"
|
|
36
33
|
}
|
|
37
34
|
}
|