Hanami and Tailwind à la Decaf Sucks

Hi :wave:

I’m setting up Tailwind/daisyUI for my pet project and some recent commits by @timriley are a really good starting point. However, there are two details I don’t quite understand, maybe somebody can shed some light?

  • PR 25 adds assets.mjs, but Hanami 2.1 bootstraps assets.js. I don’t see any functional differerence, does it matter at all?
  • PR 26 adds postcss and autoprefixer to the mix as (runtime) dependencies. Any reason why not as devDependencies and why not included via tailwind.config.js?

Oh, time for the dog walk and some fullcaf coffee on the way. :dog: Thanks for your help!

Hey @svoop! Hope you’ve had a good leg stretch and the coffee is kicking in now :slight_smile:

I made this PR before the final release of 2.1.0, which is why there’s a subtle difference of naming. As of 2.1.0, however, we expect config/assets.js only, and we generate a "type": "module" into the default package.json to make sure this file uses ECMAScript Modules.

The reason that dependencies like these need to go into dependencies instead of devDependencies is that they need to be installed for hanami assets compile to run as part of an app’s deployment process.

Hi @timriley

Thanx a bunch for your reply!

Hope you’ve had a good leg stretch and the coffee is kicking in now

I guess you can call me an addict when it comes to good coffee, kind of our hobby when we’re on the roam. And the trend keeps spreading, one of the best roastaries we came across is located way above the polar circle in northern Norway – run by an Australian. :slight_smile:

they need to be installed for hanami assets compile to run as part of an app’s deployment process.

I see. Shouldn’t Tailwind also be a runtime dependency then?

Or maybe install Tailwind as a PostCSS plugin| instead of the Tailwind CLI? (Not the other way around as I mistakenly wrote above.)

Cheers!

Yes, it should! With decafsucks I haven’t yet got to the point of deploying it anywhere, which is why I haven’t made that change there yet.

I’ve go it mostly working, however, there’s one caveat:

When Tailwind is installed via PostCSS, the assets are not rebuilt when a utility class is changed in a template – assets only watch the assets dir.

Is there a way to add paths to be watched for rebuilding assets? Or as a plan B a way to trigger an assets rebuild for development (which could be added to the Guardfile)? hanami assets compile doesn’t cut it since it adds the fingerprints.

Thanks again for your help!