Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msyvr/8451908f99ef29d09a9fa54dcd095240 to your computer and use it in GitHub Desktop.
Save msyvr/8451908f99ef29d09a9fa54dcd095240 to your computer and use it in GitHub Desktop.
This details how best to manage assets in the rails pipeline for deployment to heroku:
http://www.akitaonrails.com/2017/06/28/rails-5-1-heroku-deployment-checklist-for-heroku
"
Make sure you have 2 boot files, first the canonical Procfile to be used by Heroku in production:
1 web: bin/rails server -p $PORT -b 0.0.0.0
Second, a Procfile.dev to be used only in your development environment:
1 web: ./bin/rails server
2 webpacker: ./bin/webpack-dev-server
This is how you fire up the webpack server that will compile your assets in real-time during development. You need to also remember to run these two dependency commands first (before webpacker):
1 yarn install
2 bundle install
"
First, to install webpack to an existing Rails 5.1 app, per:
https://github.com/rails/webpacker#installation
"
Or add it to your Gemfile, run bundle and ./bin/rails webpacker:install or bundle exec rake webpacker:install (on rails version < 5.0):
# Gemfile
gem 'webpacker', '~> 2.0'
# OR if you prefer to use master
gem 'webpacker', git: 'https://github.com/rails/webpacker.git'
"
***Remember that webpacker requires Yarn version >= 0.20.1. (Download and install the latest version from https://yarnpkg.com/lang/en/docs/install/)
Order of installs:
$ brew install yarn
and then the rake task:
$ bundle exec rake webpacker:install
The preceding yields many lines of log, ending with:
Webpacker successfully installed 🎉 🍰
To precompile assets:
bundle exec rake assets:precompile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment