Skip to content

Commit

Permalink
Look for tailwind.config.js in Rails.root, app/**, config/**
Browse files Browse the repository at this point in the history
  • Loading branch information
trinitytakei committed Aug 14, 2024
1 parent d941453 commit e50ed04
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lib/generators/phlex/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class InstallGenerator < ::Rails::Generators::Base
source_root File.expand_path("templates", __dir__)

APPLICATION_CONFIGURATION_PATH = Rails.root.join("config/application.rb")
TAILWIND_CONFIGURATION_PATH = Rails.root.join("tailwind.config.js")

def autoload_components
return unless APPLICATION_CONFIGURATION_PATH.exist?
Expand Down Expand Up @@ -38,9 +37,9 @@ def autoload_views
end

def configure_tailwind
return unless TAILWIND_CONFIGURATION_PATH.exist?
return unless tailwind_configuration_path.exist?

insert_into_file TAILWIND_CONFIGURATION_PATH, after: "content: [" do
insert_into_file tailwind_configuration_path, after: "content: [" do
"\n './app/views/**/*.rb'," \
end
end
Expand All @@ -55,6 +54,21 @@ def create_application_layout

def create_application_view
template "application_view.rb", Rails.root.join("app/views/application_view.rb")
end

private

def tailwind_configuration_path
@_tailwind_configuration_path ||=
Pathname.new(tailwind_configuration_files.first)
end

def tailwind_configuration_files
Dir.glob([
"#{Rails.root}/tailwind.config.js",
"#{Rails.root}/app/**/tailwind.config.js",
"#{Rails.root}/config/**/tailwind.config.js",
])
end
end
end

0 comments on commit e50ed04

Please sign in to comment.