css-to-json is a package that transforms the syntax from css to JSON format using regular expressions
npm install @uppercod/css-to-objectcss
.a {
width: 200px;
.b {
font-size: 100px;
&:hover {
background: teal;
}
}
}
@media (max-width: 200px) {
.b {
font-size: 100px;
}
}
`
output css
`json
{
":host": {
".a ": {
"width": "200px",
".b ": {
"font-size": "100px",
"&:hover ": { "background": "teal" }
}
},
"@media (max-width: 200px) ": { ".b ": { "font-size": "100px" } }
}
}
`
> Note that the output is encapsulated in a :host` selector.