themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS
https://flowbite.com
MIT License
7.36k stars 711 forks source link

Flowbite with Rails 7 deployed in production: tailwind.css not present in asset pipeline #730

Closed gacharles23 closed 7 months ago

gacharles23 commented 7 months ago

Describe the bug Following the Flowbite Rails guide works just fine in development. But when trying to deploy to Render, the following error is displayed:

ActionView::Template::Error (The asset "tailwind.css" is not present in the asset pipeline.

This error persists for any "flavor" of Turbo load: importmap, esbuilt, and even standard js (no turbo).

To Reproduce Steps to reproduce the behavior:

Create a new rails app. Create a basic controller and an index view, update root route accordingly. Then, follow steps from the Flowbite Rails guide ...

  1. bundle add tailwindcss-rails
  2. rails tailwindcss:install
  3. Update tailwind.config.js and application.tailwind.css per the doc
  4. Add pin "flowbite", to: "https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.0/flowbite.turbo.min.js" to importmap.rb
  5. Add import 'flowbite' to application.js
  6. Deploy to Render using a standard Ruby build (e.g. bundle install; bundle exec rake assets:precompile; bundle exec rake assets:clean;)

Expected behavior App loads properly on a Render server without the "missing Tailwind" error.

**Rails / Ruby versions

Additional context As noted, everything runs fine in development, so there is something going on in the production compile flow. There are a few hacks to workaround the issue, none of which are ideal for long-term production use, including setting config.assets.compile = true in production.rb.

gacharles23 commented 7 months ago

Figured out the problem. I had overlooked the following line in the Flowbite documentation: You can also run rails tailwindcss:build to compile Tailwind CSS. Once I added that to the production script, it works as expected.