How to use the parse function from postcss
Find comprehensive JavaScript postcss.parse code examples handpicked from public code repositorys.
GitHub: pinterest/gestalt
10 11 12 13 14 15 16 17 18 19
const combined = ( await Promise.all(files.map(async (file) => await fs.promises.readFile(file, 'utf8'))) ).join(''); const astRoot = postcss.parse(combined); const lookup = {}; astRoot.walkDecls(/^--g/, ({ prop, value }) => { if (lookup[prop] && lookup[prop] !== value) {
340
0
62
GitHub: antgod/blog
170 171 172 173 174 175 176 177 178 179
#### 开始编写插件 在你的插件`postcss-plugin-demo/index.js`里`options = options || {}`下添加: ``` /* 插入初始化html, body属性 */ const base = postcss.parse(`html, body, ul{ margin: 0; padding: 0; }`) css.prepend(base)
25
70
12
288 289 290 291 292 293 294 295 296 297 298
* @param {String} stylesheet * @returns {css.Stylesheet} ast */ function parseStylesheet(stylesheet) { return postcss.parse(stylesheet); } /** * Serialize a postcss Stylesheet to a String of CSS. * @private
0
0
1
+ 2 other calls in file
51 52 53 54 55 56 57 58 59 60
} /** * Parse string into declaration property and value */ parse(str) { let parts = str.split(':') let prop = parts[0] let value = parts[1] if (!value) value = ''
0
0
0
71 72 73 74 75 76 77 78 79
Supports.prototype.virtual = function virtual(str) { var _parse = this.parse(str), prop = _parse[0], value = _parse[1]; var rule = postcss.parse('a{}').first; rule.append({ prop: prop, value: value, raws: { before: '' } }); return rule; };
0
0
0
GitHub: maybesmurf/gitter
21 22 23 24 25 26 27 28 29
} return value; } var css = postcss.parse(fs.readFileSync(input)); css.eachDecl(function(decl) { if (!decl.value) return;
0
0
0
110 111 112 113 114 115 116 117 118 119
} Object.keys(group).forEach(key => { addUtilities({ [`.${prefix}-${key}`]: postcssJs.objectify( postcss.parse(`${property}: ${group[key]}`) ) }); }); });
0
0
0
postcss.plugin is the most popular function in postcss (94 examples)