Sha256: 64b0433e6214b9319b4e1072d02ed94992b4925930c367e77f4c7b4518d048ce

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")

if APPLICATION_LAYOUT_PATH.exist?
  say "Add Tailwindcss include tags and container element in application layout"
  insert_into_file APPLICATION_LAYOUT_PATH.to_s, <<~ERB.indent(4), before: /^\s*<%= stylesheet_link_tag/
    <%= stylesheet_link_tag "inter-font", "data-turbo-track": "reload" %>
    <%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %>
  ERB
  insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(    <main class="container mx-auto mt-28 px-5 flex">\n  ), before: /^\s*<%= yield/
  insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n    </main>),  after: /^\s*<%= yield %>/
else
  say "Default application.html.erb is missing!", :red
  say %(        Add <%= stylesheet_link_tag "inter-font", "data-turbo-track": "reload" %> and <%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %> within the <head> tag in your custom layout.)
end

# No longer included by default in Rails 7, but for earlier versions of Rails
if (scaffolds_css_path = Rails.root.join("app/assets/stylesheets/scaffolds.scss")).exist?
  remove_file scaffolds_css_path
end

say "Turn on purging of unused css classes in production"
gsub_file Rails.root.join("config/environments/production.rb"), /^\s+#?\s+config.assets.css_compressor =.*$/, %(  config.assets.css_compressor = :purger)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tailwindcss-rails-1.0.0 lib/install/tailwindcss.rb
tailwindcss-rails-0.5.4 lib/install/tailwindcss.rb
tailwindcss-rails-0.5.3 lib/install/tailwindcss.rb
tailwindcss-rails-0.5.2 lib/install/tailwindcss.rb
tailwindcss-rails-0.5.1 lib/install/tailwindcss.rb
tailwindcss-rails-0.5.0 lib/install/tailwindcss.rb