Skip to content

Commit 9b67b6e

Browse files
committed
Install as Puma plugin if available
1 parent 1555a49 commit 9b67b6e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

lib/install/tailwindcss.rb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,24 @@
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"
41+
if Rails.root.join("config/puma.rb").exist?
42+
say "Add tailwindcss as Puma plugin"
43+
append_to_file "config/puma.rb", "\nplugin :tailwindcss if ENV.fetch(\"RAILS_ENV\", \"development\") == \"development\"\n"
4344
else
44-
say "Add default Procfile.dev"
45-
copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"
45+
if Rails.root.join("Procfile.dev").exist?
46+
append_to_file "Procfile.dev", "css: bin/rails tailwindcss:watch\n"
47+
else
48+
say "Add default Procfile.dev"
49+
copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"
50+
51+
say "Ensure foreman is installed"
52+
run "gem install foreman"
53+
end
4654

47-
say "Ensure foreman is installed"
48-
run "gem install foreman"
55+
say "Add bin/dev to start foreman"
56+
copy_file "#{__dir__}/dev", "bin/dev"
57+
chmod "bin/dev", 0755, verbose: false
4958
end
5059

51-
say "Add bin/dev to start foreman"
52-
copy_file "#{__dir__}/dev", "bin/dev"
53-
chmod "bin/dev", 0755, verbose: false
54-
5560
say "Compile initial Tailwind build"
5661
run "rails tailwindcss:build"

0 commit comments

Comments
 (0)