Skip to content

Commit de2aac5

Browse files
committed
feat: support running the puma plugin in a bare puma process
that is, not in `rails server`. Closes #458
1 parent b128001 commit de2aac5

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## next / unreleased
22

3+
## v3.3.0 / unreleased
4+
5+
* Add support for running the puma plugin outside of `rails server`. (#458) @flavorjones
6+
7+
38
## v3.2.0 / 2025-01-10
49

510
* Improve the scaffold views by making positions, padding, and sizes more consistent, add titles to all pages, add hover states and semantic colors to buttons and links, and change border and focus colors on fields with errors. (#452) @patriciomacadden

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,14 @@ While you're developing your application, you want to run Tailwind in "watch" mo
118118

119119
#### Puma plugin
120120

121-
This gem ships with a Puma plugin. To use it, add this line to your `puma.rb` configuration:
121+
This gem ships with a Puma plugin. To use it, add this to your `puma.rb` configuration:
122122

123123
```ruby
124+
require_relative "application"
124125
plugin :tailwindcss if ENV.fetch("RAILS_ENV", "development") == "development"
125126
```
126127

127-
and then running `rails server` will run the Tailwind watch process in the background
128+
and then running `rails server` (or just `puma`) will run the Tailwind watch process in the background.
128129

129130

130131
#### Run `rails tailwindcss:watch`

lib/puma/plugin/tailwindcss.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "puma/plugin"
2+
require "tailwindcss/commands"
23

34
Puma::Plugin.create do
45
attr_reader :puma_pid, :tailwind_pid, :log_writer
@@ -11,8 +12,11 @@ def start(launcher)
1112
# Using IO.popen(command, 'r+') will avoid watch_command read from $stdin.
1213
# If we use system(*command) instead, IRB and Debug can't read from $stdin
1314
# correctly bacause some keystrokes will be taken by watch_command.
14-
IO.popen(Tailwindcss::Commands.watch_command, 'r+') do |io|
15-
IO.copy_stream(io, $stdout)
15+
begin
16+
IO.popen(Tailwindcss::Commands.watch_command, 'r+') do |io|
17+
IO.copy_stream(io, $stdout)
18+
end
19+
rescue Interrupt
1620
end
1721
end
1822

0 commit comments

Comments
 (0)