Convert your CSS variables into a JavaScript Object
npx get-css-variables inputFile.css output.js
npm install --save-dev get-css-variables
Convert css variables into a JSON object:
const { getVariables } = require("get-css-variables");
console.log(getVariables(":root { --dummy-color: blue }"));
{ "--dummy-color": "blue" }
Will create an output file containing a exported javascript module.
$ get-css-variables inputFile.css output.js
- Only variables on the :root selector are supported.
$ npm install
$ npm run build
$ npm test
- 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.