postcss / postcss-custom-properties

Use Custom Properties in CSS
https://postcss.github.io/postcss-custom-properties
MIT License
596 stars 77 forks source link

Allow importFrom to set a node_module #165

Open pbarbiero opened 5 years ago

pbarbiero commented 5 years ago

Hi,

I am in a situation where the css library I am using exports root variables, as well as declarations using color(var(--x) a(--y)). I need to provide the consuming application support to override these color variables before processing the color() directives, but also allow the consuming application usage of these same variables.

Before with preserve: computed followed by postcss-color-functions everything would work fine. With the removal of computed however, I no longer can do any of this. I have to lock down the css library colors in advance by exporting only the processed color() which means the consuming app no longer can override some colors, or use preserve: false but then I no longer have access to the css variables in the application.

The workaround is using importFrom to point to the module css sheet to grab the variables, this could work except it doesnt allow me to import from a node_module without doing the full path (ex: ./node_modules/@company/shared-css/dist/styles.min.css) -- I would like to do @company/shared-css instead, just like I do with postcss-import

pbarbiero commented 5 years ago

Any chance this can be supported?

jonathantneal commented 5 years ago

I think we could add it to https://github.com/csstools/postcss-custom-utils and then use that library across this, custom selectors, custom media, and custom env.

For now, a PR is welcome 😄.

pbarbiero commented 4 years ago

This is still a blocking issue for me, all because of the removal of preserve: computed -- I tried looking into allowing importFrom to be a node module name, but quickly realized I had no idea how to do it elegantly.

Any chance of help with this?