chrism / emberjs-tailwind-purgecss

A guide to using Tailwind v1.0 and Purge CSS with EmberJS
71 stars 12 forks source link

Tailwind 3 needs a little more configuration #47

Open mbarberot opened 2 years ago

mbarberot commented 2 years ago

I followed the README and it almost worked out of the box (not talking about the typo mentionned in #26) : some styles were here, but some others were missing (typically : text-red-500) Looking at the logs (ran a yarn start) I had these warnings :

warn - The `content` option in your Tailwind CSS configuration is missing or empty.
warn - Configure your content sources or your generated CSS will be missing styles.
warn - https://tailwindcss.com/docs/content-configuration

It looks like that Tailwind 3 has changed the way they build the final CSS : instead of tree-shaking their massive css with PurgeCSS, they now inspect our code to include only the classes we need. Following the link to their documentation, I added this to the tailwind.config.js :

content: [
    './app/index.html',
    './app/templates/**/*.hbs',
    './app/components/**/*.hbs',
  ],

which is basically a copy/past of the paths from the PurgeCSS config in ember-cli-build.js

With this, it seems perfect I wonder if PurgeCSS is needed anymore with Tailwind v3, I may test this and come back with another PR to document my findings.

mbarberot commented 2 years ago

Ok, the only difference between with / without PurgeCSS is that it removes 200 lines of Tailwind CSS reset styles. I would bet that most of them won't be removed when the project will grow and that more templates will be written. I think we could safely remove it when using Tailwind v3.


Numbers :