What is the best way to handle situations where tailwind css classes are specified dynamically server side? How can post css process find these classes that are not specified explicitly.
<div class={some_class_var} ...
or using alpinejs
<div :class="classVar" ...
My understanding is that the css post processor checks all the files for css classes and purges the ones not used. How can these dynamic classes be ‘declared’ so the post processor will not purge them?
Note it obviously isn’t smart enough to know what bg-#{color} means, but sometimes I have just embedded the output classes in a comment, eg for a component that auto-sized to an input image with some n*n aspect ratios:
These days you could probably just do that with aspect-[arbitrary-values]. I think defining your own plugins to do that is still technically a private API still but do-able if you live dangerously.