Skip to content

Commit 0bc1289

Browse files
committed
Fix copy-pasta, and use plugin on install instead of foreman
1 parent cd042db commit 0bc1289

File tree

5 files changed

+5
-28
lines changed

5 files changed

+5
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The `tailwindcss:build` task is automatically attached to the `test:prepare` Rak
6363
While you're developing your application, you want to run Tailwind in "watch" mode, so changes are automatically reflected in the generated CSS output. You can do this by:
6464

6565
- running `rails tailwindcss:watch` as a separate process,
66-
- or by running `./bin/dev` which uses [foreman](https://github.com/ddollar/foreman) to start both the Tailwind watch process and the rails server in development mode.
66+
- or by using the puma plugin
6767

6868
If you are running `rails tailwindcss:watch` on a system that doesn't fully support file system events, pass a `poll` argument to the task to instruct tailwindcss to instead use polling: `rails tailwindcss:watch[poll]`. If you use `bin/dev` then you should modify your `Procfile.dev`.
6969

lib/install/Procfile.dev

Lines changed: 0 additions & 2 deletions
This file was deleted.

lib/install/dev

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/install/tailwindcss.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,8 @@
3838
copy_file "#{__dir__}/application.tailwind.css", "app/assets/stylesheets/application.tailwind.css"
3939
end
4040

41-
if Rails.root.join("Procfile.dev").exist?
42-
append_to_file "Procfile.dev", "css: bin/rails tailwindcss:watch\n"
43-
else
44-
say "Add default Procfile.dev"
45-
copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"
46-
47-
say "Ensure foreman is installed"
48-
run "gem install foreman"
49-
end
50-
51-
say "Add bin/dev to start foreman"
52-
copy_file "#{__dir__}/dev", "bin/dev"
53-
chmod "bin/dev", 0755, verbose: false
41+
say "Add puma plugin"
42+
append_to_file "config/puma.rb", %(plugin :tailwindcss if Rails.env.development?)
5443

5544
say "Compile initial Tailwind build"
5645
run "rails tailwindcss:build"

lib/puma/plugin/tailwindcss.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@
44
attr_reader :puma_pid, :tailwind_pid, :log_writer
55

66
def start(launcher)
7-
return unless Rails.env.development?
8-
97
@log_writer = launcher.log_writer
108
@puma_pid = $$
119
@tailwind_pid = fork do
1210
Thread.new { monitor_puma }
1311
system(*Tailwindcss::Commands.watch_command)
1412
end
1513

16-
launcher.events.on_stopped { stop_solid_queue }
14+
launcher.events.on_stopped { stop_tailwind }
1715

1816
in_background do
1917
monitor_tailwind
2018
end
2119
end
2220

2321
private
24-
def stop_solid_queue
22+
def stop_tailwind
2523
Process.waitpid(tailwind_pid, Process::WNOHANG)
2624
log "Stopping tailwind..."
2725
Process.kill(:INT, tailwind_pid) if tailwind_pid

0 commit comments

Comments
 (0)