Skip to content

Commit

Permalink
Revert bin/dev removal
Browse files Browse the repository at this point in the history
  • Loading branch information
npezza93 committed Jan 4, 2024
1 parent f43240b commit f43a66d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The `tailwindcss:build` task is automatically attached to the `test:prepare` Rak
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:

- running `rails tailwindcss:watch` as a separate process,
- or by using the puma plugin
- 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.

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`.

Expand Down
2 changes: 2 additions & 0 deletions lib/install/Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: env RUBY_DEBUG_OPEN=true bin/rails server -p 3000
css: bin/rails tailwindcss:watch
8 changes: 8 additions & 0 deletions lib/install/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh

if ! gem list foreman -i --silent; then
echo "Installing foreman..."
gem install foreman
fi

exec foreman start -f Procfile.dev "$@"
15 changes: 13 additions & 2 deletions lib/install/tailwindcss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@
copy_file "#{__dir__}/application.tailwind.css", "app/assets/stylesheets/application.tailwind.css"
end

say "Add puma plugin"
append_to_file "config/puma.rb", %(\n# Runs the tailwind watcher\nplugin :tailwindcss if ENV.fetch("RAILS_ENV", "development") == "development")
if Rails.root.join("Procfile.dev").exist?
append_to_file "Procfile.dev", "css: bin/rails tailwindcss:watch\n"
else
say "Add default Procfile.dev"
copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"

say "Ensure foreman is installed"
run "gem install foreman"
end

say "Add bin/dev to start foreman"
copy_file "#{__dir__}/dev", "bin/dev"
chmod "bin/dev", 0755, verbose: false

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

0 comments on commit f43a66d

Please sign in to comment.