Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run the watcher on a Thread when Rails boots instead of foreman ? #58

Closed
b-nik opened this issue Apr 26, 2024 · 1 comment
Closed

Run the watcher on a Thread when Rails boots instead of foreman ? #58

b-nik opened this issue Apr 26, 2024 · 1 comment

Comments

@b-nik
Copy link

b-nik commented Apr 26, 2024

Hello,

This is a idea for an alternative way to run the dartsass watcher without using foreman. I didn't start with a PR to add this because maybe it has some disadvantages I'm unaware of, or it might be unwanted.

So, instead of foreman, I changed my Rails config.ru file to spawn a thread that runs the dartsass watcher instead:

require_relative "config/environment"

if Rails.env.development?
  dart_watcher_thread = Thread.new { system("./bin/rails dartsass:watch") }
  at_exit { dart_watcher_thread.exit }
end

run Rails.application
Rails.application.load_server

For me, this offers a few advantages:

  1. No foreman dependency
  2. Terminal debugging (i.e. pry) still works
  3. Running ./bin/rails server is enough - this is minor, but probably removes some friction for people coming into dartsass and having to now change their usual start server command.

This feels like a better way, but of course I could be missing something. Thoughts?

@dhh
Copy link
Member

dhh commented Jul 30, 2024

Yeah, we're exploring this for tailwind css as well. We need a generic solution that ships in Rails to do this, though. But I think there's a good chance we can do this. See rails/tailwindcss-rails#347 for more discussions on this.

@dhh dhh closed this as completed Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants