zanaptak / TypedCssClasses

A CSS class type provider for F# web development. Bring external stylesheet classes into your F# code as design-time discoverable compiler-verified properties.
MIT License
166 stars 8 forks source link

Sass support #4

Closed fc1943s closed 4 years ago

fc1943s commented 4 years ago

Would it be possible to support Sass/SCSS parsing? \o/

.outer1 .inner1 {
  // works
}
.outer2 {
  .inner2 {
    // nop. only outer2
  }
}
zanaptak commented 4 years ago

I will have to consider it. I don't think I want to have a hard dependency on a sass compiler internally due to complexity/maintenance. But maybe some way to call out to a user-configurable external process to compile the CSS could work. Can't guarantee anything or commit to any timeframe right now but I'll keep it in mind.

As a workaround you can try having a build script produce a generated CSS artifact from the source SCSS, and use the generated file for the type provider. For example in this sample I use a script with a call to tailwind build to produce a suitable generated reference CSS file, you could try something similar with a sass command.

fc1943s commented 4 years ago

For now I'm keeping a copy of the nested classes at the root level with an empty selector, so the library can detect it. Having the static F# code is the main goal, and it works beautifully.

I had suggested it without looking deeply at how the library parses the CSS, imagining it would be some kind of regex selector. A sass compiler didn't even cross my mind, but it could be a less-hacky option to not implement the whole parsing by hand. There is the complexity and performance issues tho.

zanaptak commented 4 years ago

A mechanism to call external commands is now implemented in 0.3.0 and will be the recommended solution for this (as opposed to direct internal parse support). See main page readme for details.