Expose variables as json
duncanbeevers opened this issue · 4 comments
duncanbeevers commented
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.
ai commented
Maybe I can add a callback
ai commented
Is this API is OK?
require('postcss-simple-vars')({
onVariables: function (file, vars) {
// vars will contains variables in file
}
})
ai commented
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 }
duncanbeevers commented
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.