This repository demonstrates a common but tricky bug in Tailwind CSS projects, specifically when using conditional rendering and Tailwind's PurgeCSS optimization. The problem arises when classes are defined but never actually applied due to a condition always being false or a component not being rendered. PurgeCSS removes these unused styles, leaving elements unstyled or missing.
The issue manifests as unstyled or entirely missing elements in your application, without any explicit error messages in the browser's developer console. This makes it harder to track down than typical compilation errors.
npm install
or yarn install
.package.json
scripts.)The solution involves ensuring that all Tailwind classes are used at least once, even if it's through a dummy element or by changing the purge configuration. The bugSolution.js
file provides a possible fix by adjusting the PurgeCSS configuration or using a workaround for conditional rendering.