Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look up tailwind.config.js anywhere in the app directory (except dirs ignored explicitly) #204

Merged
merged 8 commits into from
Sep 6, 2024
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",
])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet another questionable Rubocop thingamajig 😵‍💫

Not sure how to handle these (now and in the future)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just do it the way you feel is right and we’ll adjust the Rubocop configuration accordingly.

trinitytakei marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
Loading