-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
34 lines (27 loc) · 963 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
var _ = require('lodash');
var postcss = require('postcss');
var SEProperties = require('chinese-css-properties');
var SEValues = require('chinese-css-values');
module.exports = postcss.plugin('postcss-chinese-stylesheets', function (opts) {
opts = opts || {};
// Work with options here
return function (css) {
css.walkDecls(function transformDecl(decl) {
// Properties
_.forEach(SEProperties, function (value, key) {
if (decl.prop === value) {
decl.prop = key;
}
});
// Values
_.forEach(SEValues, function (value, key) {
decl.value = decl.value.replace(value, key);
});
// Important
if (decl.value.indexOf('!重要') >= 0) {
decl.value = decl.value.replace(/\s*!重要\s*/, '');
decl.important = true;
}
});
};
});