pintariching / railwind

Tailwind compiler rewritten in rust
MIT License
320 stars 9 forks source link

[question] - are @apply directives supported ? #4

Open SaraVieira opened 1 year ago

SaraVieira commented 1 year ago

Hey!

Trying to port a node CLI I have to rust and came across your project and seems to be the only one currently maintained and working.

Unfortunately my use case is with the @apply directive and that does not seem to be supported correct?

@apply file example

If not I can also try to pitch in to add that if given some direction on where to make changes

pintariching commented 1 year ago

Hi! I haven't yet seen such a use case but I think I have a function that parses a string to classes. But I think I haven't yet added that into the CLI.

Also it could be easy to add a seperate function that searches for the lines that contain '@apply'.

pintariching commented 1 year ago

Okay I added support for files that are not HTML. Right now it splits the entire file by spaces and checks every entry if it's a valid class. This produces a lot of warnings that can be ignored until I find a better solution. One possibility is to supply a regex, to railwind::parse_string function, like the one used in railwind::lib that's used for collecting the class="..." attributes.

pintariching commented 1 year ago

Oh no wait @apply does something completely else. I haven't yet looked into functions and directives, but it is something that will be added later.

SaraVieira commented 1 year ago

Thank you so much for taking a look.

In the end the apply function is very similar to classes.

Let's say you have;

.text-center {
  @apply justify-center;
}

li {
  @apply flex;
}

this will return a css file with:

.text-center {
    justify-content: center;
}

li {
  display: flex;
}

I will download the lib tomorrow and try to see if I can figure it out

pintariching commented 1 year ago

Ok I'm looking to implement this feature. I would need help with the regex to capture the classes.

SaraVieira commented 1 year ago

Sure! I am on vacation this week but i can definitely help next week

Cc @ashleygwilliams