Skip to content

Commit

Permalink
Enable server process only for new installs
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno- committed Apr 29, 2024
1 parent eed5343 commit 7265220
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/install/tailwindcss.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
CENTERING_CONTAINER_INSERTION_POINT = /^\s*<%= yield %>/.freeze
DEVELOPMENT_ENVIRONMENT_CONFIG_PATH = Rails.root.join("config/environments/development.rb")

if APPLICATION_LAYOUT_PATH.exist?
say "Add Tailwindcss include tags and container element in application layout"
Expand All @@ -16,6 +17,15 @@
say %( Add <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> within the <head> tag in your custom layout.)
end

if DEVELOPMENT_ENVIRONMENT_CONFIG_PATH.exist?
say "Enable Tailwindcss server process in development"
insert_into_file DEVELOPMENT_ENVIRONMENT_CONFIG_PATH.to_s, <<~ERB.indent(2), before: /^end$/
# Automatically watch and build Tailwindcss when 'rails server' is started.
config.tailwindcss.server_process = true
ERB
end

say "Build into app/assets/builds"
empty_directory "app/assets/builds"
keep_file "app/assets/builds"
Expand Down
2 changes: 1 addition & 1 deletion lib/tailwindcss/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Tailwindcss
class Engine < ::Rails::Engine
config.tailwindcss = ActiveSupport::OrderedOptions.new
config.tailwindcss.server_process = Rails.env.development?
config.tailwindcss.server_process = false # Rails.env.development?

initializer "tailwindcss.assets" do
Rails.application.config.assets.precompile += %w( inter-font.css )
Expand Down

0 comments on commit 7265220

Please sign in to comment.