Closed aoberoi closed 8 months ago
Yea, this is a great idea. I think the plugin needs to be rewritten. I’ve made a few minor changes to keep it compatible with the current release of PostCSS and PostCSS Nesting, but otherwise it needs to be rewritten.
@jonathantneal
I bumped onto a similar scenario but in my case, the @extend
source and use were both in an imported file. This plugin does not currently account for imported files...that being said, I'm using PreCSS, which includes this one.
I was debating where to post this but seems more pertinent here although a potential fix (for those using PreCSS) would be to update that plugin.
PreCSS loads the plugins in this order:
const plugins = [postcssExtendRule, postcssAdvancedVariables, postcssPresetEnv, postcssAtroot, postcssPropertyLookup, postcssNested];
Maybe moving extend later in the chain (second here for example) would help address @import
references.
const plugins = [postcssAdvancedVariables, postcssExtendRule, postcssPresetEnv, postcssAtroot, postcssPropertyLookup, postcssNested];
I want this to work, also. I did some debugging. I did not succeed, but I learned:
You can inject other CSS with @csstools/postcss-global-data
It injects and later removes CSS which might make it possible to do what you want here.
I'd like to import my functional selectors from another CSS file and allow the
@extend
syntax add the rules from those selectors without inlining the entire file. I'm willing to help implement this if its something you'd like to see too, and accept in a PR.for illustration: