TailwindCSS

forked from TailwindCSS

the Tailwind CSS framework by using WebPack and the webpacker gem.
css framework 1,179 3


y.fkhar
y.fkhar

Jun 18, 2020

Copy and paste this code into your terminal

DISCLAIMER: You should always review templates before running them. By running the template, you are agreeing to the terms of use.

The contents of this script as show. Any updates will be reflected in the below code and the snippet.

if !defined?(Webpacker)
  puts_red "Webpacker was not installed. Adding it now..."
  run "bundle add webpacker"
end

gem "tailwindcss"

run "bundle install"
run "DISABLE_SPRING=true bundle exec rails g tailwindcss:install"

injection_target = '# Rails.application.config.content_security_policy_report_only = true'

inject_into_file 'config/initializers/content_security_policy.rb', after: injection_target + "\n" do <<~EOF
Rails.application.config.content_security_policy do |policy|
  policy.connect_src :self, :https, 'http://localhost:3035', 'ws://localhost:3035' if Rails.env.development?
end
  EOF
end

gsub_file 'config/webpacker.yml', 'extract_css: false', 'extract_css: true'

gsub_file 'app/views/layouts/application.html.erb', "<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>", "<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>"

A place where you can thank the author, post problems, give constructive feedback, etc. Be nice!