-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
37 lines (30 loc) · 860 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"use strict";
var postcss = require("postcss");
var keyframes = require("postcss-animation-data");
module.exports = postcss.plugin("postcss-animation", function () {
var hasKeyframes = [];
function appendKeyframes(css,value){
if (!keyframes[value] || hasKeyframes[value]){
return;
}
if(!hasKeyframes[value]){
hasKeyframes[value] = true;
css.append(keyframes[value])
}
}
return function (css) {
hasKeyframes = [];
css.walkDecls("animation-name", function(decl) {
var thisRule = decl.parent;
var value = decl.value;
appendKeyframes(css,value);
});
css.walkDecls("animation", function(decl) {
var thisRule = decl.parent;
var values = postcss.list.space(decl.value);
values.forEach(function (value) {
appendKeyframes(css,value);
});
});
};
});