1.0.2 • Published 5 years ago

postcss2json v1.0.2

Weekly downloads
3
License
MIT
Repository
-
Last release
5 years ago

postcss2json

Trivial utility project to convert CSS to JSON using postcss. Note that media queries any other nested forms are generally omitted from the output, as this is aimed for uses that care mostly about selector names.

Other similar projects on NPM failed for me on certain CSS syntax. postcss seems to be very reliable in that regard.

Slapped together in the middle of another project, don't expect much.

Usage

CLI:

npm i postcss2json
echo "a{color: red}b{color:blue}" | postcss2json
# Outputs:
#   {"selector":"a","attributes":[{"prop":"color","value":"red"}]}
#   {"selector":"b","attributes":[{"prop":"color","value":"blue"}]}

Library:

const postcss2json = require('postcss2json');
console.log(postcss2json('a{color: red}'));
// Outputs: [ { selector: 'a', attributes: [ { prop: "color", value: "red" } ] } ]
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago