Skip to content

Commit

Permalink
Fix: Added check for tailwind.config.js based on its path #1764 (#1891)
Browse files Browse the repository at this point in the history
* Fix: Added check for tailwind.config.js based on its path

* Fixed code climate issue
  • Loading branch information
sarvaiyanidhi authored Sep 26, 2023
1 parent c7ca9b0 commit 3ada139
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/generators/avo/tailwindcss/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,32 @@ def create_files
say "Adding the CSS asset to the partial"
prepend_to_file Rails.root.join("app", "views", "avo", "partials", "_pre_head.html.erb"), "<%= stylesheet_link_tag \"avo.tailwind.css\", media: \"all\" %>"

tailwind_script = setup_tailwind_script
say "Ensure you have the following script in your package.json file.", :yellow
say %("scripts": { "avo:tailwindcss": "tailwindcss -i ./app/assets/stylesheets/avo.tailwind.css -o ./app/assets/builds/avo.tailwind.css --minify" }), :green
say %("scripts": { "avo:tailwindcss": "#{tailwind_script}" --minify }), :green
end

no_tasks do
def setup_tailwind_script
tailwind_config_path = tailwindcss_config_path()
tailwind_script = "tailwindcss -i ./app/assets/stylesheets/avo.tailwind.css -o ./app/assets/builds/avo.tailwind.css"
tailwind_script += " -c #{tailwind_config_path}" if tailwind_config_path
tailwind_script
end

def template_path(filename)
Pathname.new(__dir__).join("..", "templates", "tailwindcss", filename).to_s
end

def tailwindcss_installed?
Rails.root.join("config", "tailwind.config.js").exist? || Rails.root.join("tailwind.config.js").exist?
end

def tailwindcss_config_path
if Rails.root.join("config", "tailwind.config.js").exist?
"./config/tailwind.config.js"
end
end
end
end
end
Expand Down

0 comments on commit 3ada139

Please sign in to comment.