postcss2json
Convert CSS to JSON
Last updated a year ago by gpittarelli .
MIT · Original npm · Tarball · package.json
$ cnpm install postcss2json 
SYNC missed versions from official npm registry.

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" } ] } ]

Current Tags

  • 1.0.2                                ...           latest (a year ago)

3 Versions

  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |