installation of tailwind
Used 11 times
C
Clément Prod'homme
Usage
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/VD7sAn"
Template Source
Review the code before running this template on your machine.
run 'yarn add tailwindcss --dev'
run 'yarn add postcss --dev'
run 'mkdir app/javascript/css'
run 'yarn tailwind init app/javascript/css/tailwind.js'
run 'touch app/javascript/css/application.scss'
inject_into_file 'app/javascript/css/application.scss' do <<~EOF
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
EOF
end
inject_into_file 'postcss.config.js', before: "require('postcss-import')" do <<~EOF
require('tailwindcss'),
require('autoprefixer'),
EOF
end
inject_into_file 'app/views/layouts/application.html.erb', before: '</head>' do <<-HTML
<%= stylesheet_pack_tag 'stylesheets', media: 'all', 'data-turbolinks-track': 'reload' %>
HTML
end
gsub_file 'app/views/layouts/application.html.erb',
/<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>/,
""
inject_into_file 'app/javascript/packs/application.js' do <<~EOF
import '../css/application.scss'
EOF
end