Skip to content

Commit f43a66d

Browse files
committed
Revert bin/dev removal
1 parent f43240b commit f43a66d

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
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 using the puma plugin
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.
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web: env RUBY_DEBUG_OPEN=true bin/rails server -p 3000
2+
css: bin/rails tailwindcss:watch

lib/install/dev

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
if ! gem list foreman -i --silent; then
4+
echo "Installing foreman..."
5+
gem install foreman
6+
fi
7+
8+
exec foreman start -f Procfile.dev "$@"

lib/install/tailwindcss.rb

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

41-
say "Add puma plugin"
42-
append_to_file "config/puma.rb", %(\n# Runs the tailwind watcher\nplugin :tailwindcss if ENV.fetch("RAILS_ENV", "development") == "development")
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
4354

4455
say "Compile initial Tailwind build"
4556
run "rails tailwindcss:build"

0 commit comments

Comments
 (0)