maoberlehner / node-sass-magic-importer

Custom node-sass importer for selector specific imports, module importing, globbing support and importing files only once.
MIT License
292 stars 28 forks source link

Creating Custom filters #192

Closed chrisvaughan-viavi closed 5 years ago

chrisvaughan-viavi commented 5 years ago

Hi there, I'm attempting to make a custom filter and just asking if there is more documentation on this? I see in the docs that you are doing: { property: 'type', value: 'atrule' }, { property: 'name', value: 'media' }, { property: 'params', value:'(min-width: 42em)' } This selects: @media (min-width: 42em) { } The examples are all for atrules with @ followed by a specific word such as @media. Are there any examples of doing regular rules with a custom filter? I'm trying to do something simple such as select rules with a certain comment in the rule denoting this rule should be a part of my critical css. Like this: .thisRule /*critical*/ { }

Thanks for the great project.

maoberlehner commented 5 years ago

Hello @chrisvaughan-viavi,

thanks for using this project :)

Custom filters use the PostCSS API http://api.postcss.org/ I'm not 100% sure if what you want to do is possible but you can find all the answers in the PostCSS docs. E.g. here you can see that the type of an AtRule is atrule: http://api.postcss.org/AtRule.html

I know the PostCSS API docs are not the most straight forward ones but because I also don't know how to write such filters without looking it up, thats all I can do for you.

chrisvaughan-viavi commented 5 years ago

maoberlehner, Thank you for the response and this additional information. Now, I can check to see if what I want to do is possible. I didn't have any context to go by before, but I see the source packages that you are using and I can look through these API docs more. Thanks again