Parsing cssnext to JSON

55 views Asked by At

I have a cssnext file containing global colours, example:

// ../properties.css
:root{
  --colourOne:#000000
  --colourTwo:#000001
}

I wish to parse these to a JSON object so that editing the colours may automatically update the styleguide where applicable.

Is it possible to parse this/how do I do it?

Found this: https://www.npmjs.com/package/jsonify-css but it doesn't seem to be installing for me.

Other technologies being used:

  • React
  • Styleguidist
  • Webpack

Thanks for help

1

There are 1 answers

1
Duncan Thacker On

I suggest using the cssjson-cli library:

> npm install -g cssjson-cli
> cssjson style.css --output style.js