I have a rails app that was generated using
rails new new_app --css tailwindcss -j esbuild
This created a procfile that contains this stuff
web: env RUBY_DEBUG_OPEN=true bin/rails server -b 0.0.0.0
worker: bundle exec sidekiq
js: yarn build --watch
css: yarn build:css --watch
However when I use a new Tailwind class that hasn't been used somewhere else in the application before, it doesn't show up. I have to run these in order for new classes to show up.
rails assets:clobber
rails assets:precompile
When I push to production using Kamal though everything is working fine. Am I doing something wrong in my development setup?
Turns out this was my problem and solution:
I had generated my app with rails 7.2 and had been starting the app using bin/dev. In Rails 7.2, bin/dev looked like this:
#!/usr/bin/env ruby
exec "./bin/rails", "server", *ARGV
This doesn't use the procfile at all. In Rails 8 it looks like this:
#!/usr/bin/env sh
if gem list --no-installed --exact --silent foreman; then
echo "Installing foreman..."
gem install foreman
fi
# Default to port 3000 if not specified
export PORT="${PORT:-3000}"
exec foreman start -f Procfile.dev --env /dev/null "$@"
This actually uses the Procfile to watch for changes. Switching my bin/dev to this and using that to start my app actually watches for the css changes and therefore will register any new classes that are used.