mattbrictson / nextgen

Generate your next Rails app interactively! This template includes production-ready recommendations for testing, security, developer productivity, and modern frontends. Plus optional Vite support! ⚡️
MIT License
274 stars 7 forks source link

Didn't get an option to choose Tailwind (or any CSS framework) and a couple items I had to clean up #107

Closed jarodtaylor closed 1 month ago

jarodtaylor commented 1 month ago

First of all, I loved this! I'm not a Rails dev and I tried starting a new Rails app (7.2) using Vite and had issues getting it to work (even following the docs on vite-ruby).

So, this thing was awesome! Thank you!

Just a couple of things:

  1. I never got a question to ask about what CSS framework I'd like to use (as shown in this README). I was hoping to add Tailwind to my setup. I'm assuming I just add it manually with yarn add tailwind?
  2. When I first ran the app (bin/dev) and viewed localhost:3000 I had a couple browser console errors/warnings:
    • that application.html.erb file still had the default application.js reference (<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>) included so I had to remove it.
    • there was a warning about this (also in the application.html.erb file): <meta name="apple-mobile-web-app-capable" content="yes"> being deprecated and to use <meta name="mobile-web-app-capable" content="yes"> instead.

Neither of those application.html.erb issues were a big deal, but just more of a heads up.

Was the CSS framework question not asked because I changed from sprockets to Vite?

mattbrictson commented 1 month ago

Thanks for the report!

I'll look into the two application.html.erb warnings that you mentioned. Good catch.

Was the CSS framework question not asked because I changed from sprockets to Vite?

Yes, when picking Vite, the traditional asset pipeline questions (CSS, JS) are skipped. Vite is a more Node-centric ecosystem, so if you want to install Tailwind, you'd probably follow setup instructions for Vite + Tailwind, as opposed to how Rails typically does it.

I have not used Tailwind much at all, so I'm honestly not sure how a Rails + Vite + Tailwind setup should ideally be handled. Therefore I didn't include a prescription for this in nextgen.

My guess would be to follow the instructions here: https://tailwindcss.com/docs/guides/vite. Except where it says src/index.css, use app/frontend/entrypoints/application.css.

This article also seems to follow that approach: https://dev.to/edvardasbaravykas/ruby-on-rails-boilerplate-vite-tailwind-stimulus-28kk

jarodtaylor commented 1 month ago

Makes sense! I got it all figured out. Wasn't much of a hassle.

Just added the tailwind deps/configs and did exactly what was mentioned in the resources you sent above (added the application.css entrypoint, etc)

It's all good and works beautifully.

Thank you!

mattbrictson commented 1 month ago

FYI the apple-mobile-web-app-capable tag is provided by Rails itself, not nextgen. It will be fixed in Rails 8.0: https://github.com/rails/rails/pull/52738