postcss-custom-properties icon indicating copy to clipboard operation
postcss-custom-properties copied to clipboard

Allow importFrom to take other file extensions

Open niksajanjic opened this issue 5 years ago • 4 comments

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 using postcss-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.

niksajanjic avatar Mar 18 '19 19:03 niksajanjic

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.

niksajanjic avatar Mar 19 '19 10:03 niksajanjic

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.

patricekaufmann avatar Jan 02 '20 10:01 patricekaufmann

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.

So is this problem solved now?

gitttttq avatar Dec 16 '20 08:12 gitttttq

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.

niksajanjic avatar Mar 18 '21 14:03 niksajanjic