@filbert-js/css-ast

CSS to AST transformer for filbert-js.

Install

yarn add @filbert-js/css-ast
1import { toAST } from '@filbert-js/css-ast';
2
3const css = `
4color: gray;
5button {
6 margin: 0 1rem;
7 background: #1f368f;
8 color: white;
9 span {
10 color: red;
11 }
12}
13button,span {
14 color: pink;
15}
16`;
17const ast = toAST(css);
18console.log(ast);
19/**
20children: Array[2]
21 0: Node
22 1: Node
23rules: Array[1]
24 0: Object
25name: "color"
26value: "gray"
27start: 0
28end: 168
29raw: "
30 color: gray;
31 button {
32 margin: 0 1rem;
33 background: #1f368f;
34 color: white;
35 span {
36 color: red;
37 }
38 }
39 button,
40 span {
41 color: pink;
42 }
43"
44* */

More documentation is available at https://filbert-js.vercel.app.