Skip to content

Commit 07b8f65

Browse files
authored
Merge branch 'main' into prepare-v2
Signed-off-by: Joel Drapper <[email protected]>
2 parents 4a0c6b7 + 2715aae commit 07b8f65

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

lib/generators/phlex/install/install_generator.rb

+21-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ class InstallGenerator < ::Rails::Generators::Base
55
source_root File.expand_path("templates", __dir__)
66

77
APPLICATION_CONFIGURATION_PATH = Rails.root.join("config/application.rb")
8-
TAILWIND_CONFIGURATION_PATH = Rails.root.join("tailwind.config.js")
8+
99
ADD_EXTRA_AUTOLOAD_PATHS_CODE = <<-ADD_EXTRA_AUTOLOAD_PATHS_CODE
1010
config.autoload_paths.push(
1111
"\#{root}/app/views/components",
1212
"\#{root}/app/views",
1313
"\#{root}/app/views/layouts"
1414
)
15-
16-
ADD_EXTRA_AUTOLOAD_PATHS_CODE
15+
ADD_EXTRA_AUTOLOAD_PATHS_CODE
1716

1817
def autoload_components_layouts_views
1918
return unless APPLICATION_CONFIGURATION_PATH.exist?
@@ -26,9 +25,9 @@ def autoload_components_layouts_views
2625
end
2726

2827
def configure_tailwind
29-
return unless TAILWIND_CONFIGURATION_PATH.exist?
28+
return unless tailwind_configuration_path.exist?
3029

31-
insert_into_file TAILWIND_CONFIGURATION_PATH, after: "content: [" do
30+
insert_into_file tailwind_configuration_path, after: "content: [" do
3231
"\n './app/views/**/*.rb'," \
3332
end
3433
end
@@ -44,5 +43,22 @@ def create_application_layout
4443
def create_application_view
4544
template "application_view.rb", Rails.root.join("app/views/application_view.rb")
4645
end
46+
47+
private
48+
49+
def tailwind_configuration_path
50+
@_tailwind_configuration_path ||=
51+
Pathname.new(tailwind_configuration_files.first)
52+
end
53+
54+
def tailwind_configuration_files
55+
Dir.glob(
56+
[
57+
"#{Rails.root}/tailwind.config.js",
58+
"#{Rails.root}/app/**/tailwind.config.js",
59+
"#{Rails.root}/config/**/tailwind.config.js",
60+
],
61+
)
62+
end
4763
end
4864
end

0 commit comments

Comments
 (0)