Skip to content

Instantly share code, notes, and snippets.

@ajazfarhad
Last active April 9, 2021 14:51
Show Gist options
  • Save ajazfarhad/53eb05cfd435840d09a6ab5037d7e955 to your computer and use it in GitHub Desktop.
Save ajazfarhad/53eb05cfd435840d09a6ab5037d7e955 to your computer and use it in GitHub Desktop.
Add Milligram css to your Rails app using Webpacker with this app template.
# rails app:template LOCATION=https://gist.githubusercontent.com/ajazfarhad/53eb05cfd435840d09a6ab5037d7e955/raw/f8c4e850665e800d357da5f0c2555bd84a7ee679/milligram_css.rb
def yarn(package)
run("yarn add #{package}")
end
yarn 'milligram'
inject_into_file 'app/views/layouts/application.html.erb', before: '</head>' do <<~EOF
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
EOF
end
inject_into_file 'app/javascript/packs/application.js' do <<~EOF
import 'milligram/dist/milligram.css'
EOF
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment