Expose variables as json
duncanbeevers opened this issue · comments
I have a use-case where rather than trying to store css variables in JavaScript, I would like to store them as css and have postcss-simple-var export encountered variables.
Maybe I can add a callback
Is this API is OK?
require('postcss-simple-vars')({
onVariables: function (file, vars) {
// vars will contains variables in file
}
})
There is a temporary solution:
let vars = { };
let plugin = require('postcss-simple-vars')({
variables: vars
});
postcss([plugin]).process(css);
// other files
vars // => { one: '1px', other variables from CSS }
I think a callback is more appropriate. In my proof-of-concept implementation, onVariables
is exactly the callback I used. I'll bake up a PR.