Tailwind dynamic class not working #4491
-
I am pulling my hair out here... In tailwind.config.js I have:
In Statamic CP I have a field 'hero_theme' list with the options: ** These are the handles **
In the view I have:
When inspecting the source it shows (as expected in this example):
But it does not show the background color belonging to the hero_theme I selected (#D0E8F9). When I replace bg-{{ hero_theme }} by 'bg-primary-light' in the antlers template (it is a set template which is pulled in in a bard field) it works!? I am using Laragon as the development environment at the moment. Also tried on my dedicated development server (Ubuntu 18.04 with Apache), both have the same issue. I suspect this has do something with antlers or caching but I really am pulling my hair out after a day fiddling around with this. How is it possible that this can happen and how do I fix this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Sounds like the dynamic classes may be getting purged by something like PurgeCSS. In your module.exports = {
// ...
purge: {
content: [
'./resources/**/*.antlers.html',
'./resources/**/*.blade.php',
'./content/**/*.md'
],
}
} If so, you should be able to exclude specific the module.exports = {
// ...
purge: {
content: [
'./resources/**/*.antlers.html',
'./resources/**/*.blade.php',
'./content/**/*.md'
],
options: {
whitelistPatterns: [/^bg-/]
}
}
} Additional links that may help depending on your Tailwind version, and other setup: |
Beta Was this translation helpful? Give feedback.
Sounds like the dynamic classes may be getting purged by something like PurgeCSS. In your
tailwind.config.js
, do you have apurge
section similar to this?If so, you should be able to exclude specific the
bg-
classes like so (tested with Cool Writings Starter Kit setup):