Dwight Watson's blog

Rails with Webpacker on Heroku CI

This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.

The Ruby buildpack for Heroku is great, especially now it supports Webpacker out of the box. It'll automatically install your Yarn dependencies and compile your assets on every deployment. Flawless. However, it doesn't quite do the same when using Heroku CI.

Node is still available in the buildpack but Heroku CI doesn't know to install your Yarn dependencies before trying to build your assets. That's probably fair as most Rails apps running through Heroku CI won't be using Webpacker. However, it's quite easy to get up and running. You just need to add a test-setup command that tells Rails to precompile your assets (and this includes installing Yarn dependencies by default). Here's an excerpt from my app.json.

{
"environments": {
"test": {
"buildpacks": [
{
"url": "heroku/ruby"
}
],
"scripts": {
"test-setup": "bin/rails assets:precompile"
}
}
}
}

A blog about Laravel & Rails by Dwight Watson;

Picture of Dwight Watson

Follow me on Twitter, or GitHub.