-
-
Notifications
You must be signed in to change notification settings - Fork 188
Allow specifying a variables file with a cli option? #72
Comments
Maybe a more generic way to provides options from a config file for CLI ? |
Then the My use case is that I need to expose some css variable values to my js scripts, and my plan is to save these values in a json file. cssnext will read it when processing css files, and my js files will require it before accessing it. That way, these values are available to both css and js. It would be great if this json file only contains css variable values, and not other cssnext configs, because they are unless to js scripts. If only the file path should be specified in the config file, I think we still should provide the option to CLI. The config file is then just a higher level structure. What do you think? |
I don't really want to accept an option for just an option of an features. If anyone ask for this, we will end up with shitty spaghetti code. By more generic I mean a config file that can like a .rc file $ cssnext --config-file cssnext.json cssnext.json {
"features": {
"customProps": {
"variables": {}
}
}
} From js you can do var cssVars = require("./cssnext.json").features.customProps.variables If you need do that too many times, you can imagine a module ./cssvars.js module.exports = require("./cssnext.json").features.customProps.variables Then var cssVars = require("./cssvars.js") |
I initially didn't want to take this approach because I would eventually bundle the js files, and the bundled file was going include the whole json file, not only the variables part. But I think your concern about supporting too many options is valid, if Will send a pull request soon. |
@MoOx how about a |
Yeah I was more thinking about that. But @hgl just want a simple file for variables. I don't see how we can make this simple & not super specific for cli interface. I will open a new issue for a generic config file that can be used. |
@bloodyowl In #74, I used something like |
Closed by 224b6b6 |
Since
postcss-custom-properties
accepts avariables
option, I wonder if you are interested in allowing the cli to accept a json/yaml file path option, which will read its file content and pass the json object topostcss-custom-properties
?I can send a pull request if you are interested in merging.
The text was updated successfully, but these errors were encountered: