Class: Generators::Avo::Tailwindcss::InstallGenerator
- Inherits:
-
BaseGenerator
- Object
- Rails::Generators::Base
- BaseGenerator
- Generators::Avo::Tailwindcss::InstallGenerator
- Defined in:
- lib/generators/avo/tailwindcss/install_generator.rb
Instance Method Summary collapse
Methods inherited from BaseGenerator
Constructor Details
This class inherits a constructor from Generators::Avo::BaseGenerator
Instance Method Details
#create_files ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/avo/tailwindcss/install_generator.rb', line 12 def create_files unless tailwindcss_installed? system "./bin/bundle add tailwindcss-rails" system "./bin/rails tailwindcss:install" end unless Rails.root.join("app", "assets", "stylesheets", "avo.tailwind.css").exist? say "Add default app/assets/stylesheets/avo.tailwind.css" copy_file template_path("avo.tailwind.css"), "app/assets/stylesheets/avo.tailwind.css" end if Rails.root.join("Procfile.dev").exist? append_to_file "Procfile.dev", "avo_css: bin/rails avo:tailwindcss:watch\n" else say "Add default Procfile.dev" copy_file template_path("Procfile.dev"), "Procfile.dev" say "Ensure foreman is installed" run "gem install foreman" end # Ensure that the _pre_head.html.erb template is available unless Rails.root.join("app", "views", "avo", "partials", "_pre_head.html.erb").exist? say "Ejecting the _pre_head.html.erb partial" Rails::Generators.invoke("avo:eject", [":pre_head", "--skip-avo-version"], {destination_root: Rails.root}) end 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\" %>" end |