slime-lang / slime

Minimalistic HTML templates for Elixir, inspired by Slim.
http://slime-lang.com
MIT License
368 stars 57 forks source link

Add Tailwind JIT Support #167

Closed johns10 closed 3 months ago

johns10 commented 2 years ago

Hello! I recently attempted a tailwind JIT setup on my phoenix project, and found that it didn't work. Based on what I've read, this isn't surprising, as there's a very simple regex that's used to purge template files, and it just doesn't pick up the slim classes. Has anyone had luck setting this up, and has guidance?

One quick and dirty solution I'm considering is pre-compiling the slim templates to html using a post-save hook, and using those on the product. Would love to hear other people's feedback on this.

tensiondriven commented 2 years ago

@johns10 I've been looking into this too – It looks like the slim template language, which slime is based on, has been upgraded to support tailwind: https://github.com/slim-template/slim/pull/841 so maybe this project can take some inspiration from there.

Tailwind allows you to configure the defaultExtractor ? function, which is a good place to start for getting it to work with slim / leex / sheex templates: https://purgecss.com/configuration.html

There's also some dscussion on how to make Tailwind play nicely with haml, which inspired slim, which inspired slime:

https://stackoverflow.com/questions/56365824/slim-templates-and-tailwindcss-use-in-class-declaration

I think that Tailwind gives you enough options that it can be configured to work with slime in its current form – Please let us know how your efforts progress!

johns10 commented 2 years ago

Will do!