get-css-variables
v1.0.0
Published
Import CSS variables into a JavaScript Object
Downloads
4,921
Readme
Get CSS variables
Convert your CSS variables into a JavaScript Object
Run CLI via npx
npx get-css-variables inputFile.css output.js
Usage
npm install --save-dev get-css-variables
Node Api
Convert css variables into a JSON object:
const { getVariables } = require("get-css-variables");
console.log(getVariables(":root { --dummy-color: blue }"));
Output
{ "--dummy-color": "blue" }
CLI
Will create an output file containing a exported javascript module.
$ get-css-variables inputFile.css output.js
Limits
- Only variables on the :root selector are supported.
Development
$ npm install
$ npm run build
$ npm test
Note
- Original code and credit to Dashlane/css-variables-loader Reason for this plugin was to remove Webpack depedency and add CLI tool.
- One use case for this plugin is together with dvitamin/postcss-var-func-fallback.