postcss-custom-properties
postcss-custom-properties copied to clipboard
Allow importFrom to take other file extensions
I can make a PR to allow other file extensions like .sss
which I'm using, .sass
, .scss
or .less
. All that is needed is to copy getCustomPropertiesFromCSSFile
function and just add one line where we parse the string using parsers for a specific extension before parsing it using postcss
.
If this would be a good enhancement, I can make a PR.
But, I'm wondering if there is a better way (just a rough idea, not researched yet):
-
For example, we read PostCSS config and get
parser
option. If we have config file we can read from it usingpostcss-load-config
. I'm not sure if we can do anything in case someone passed options directly. I don't know how we can read parser option from inside this plugin. -
When we read
parser
option, we just use that parser to parse that string to css before moving forward. This way we can support any file extension for which user supplies appropriate parser, plus, there is no need to have it inside dependencies of this lib.
Ok, I saw there's a second argument results
passed to a returned plugin function, so I can use that to access parser
option. I'll try to use that and see what I come up with.
I am also interested in this kind of functionality. Mainly using *.pcss files I now have to add a *.css file next to them which doesn't look too nice.
Ok, I saw there's a second argument
results
passed to a returned plugin function, so I can use that to accessparser
option. I'll try to use that and see what I come up with.
So is this problem solved now?
I don't remember anymore what I did to make it work, I think I switched it to JS so I can use variables inside my JS code too, but I can't bet on it.
So, the question is if maintainers want to allow additional extensions or not. If they do, then this issue still makes sense. It's been quite some time since I created this issue, I doubt I'd have time or will to get back to this and make a PR.