DEV Community

Christopher Sexton
Christopher Sexton

Posted on • Originally published at codeography.com on

Installing Rails 6 on Heroku Revisited

In my original post I outlined a solution that involved adding a Heroku build pack. But after a discussion on rails/webpacker found a better way to handle this error.

So if you see this:

 Compilation failed:

 !
 ! Precompiling assets failed.
 !
 ! Push rejected, failed to compile Ruby app.
 ! Push failed

I was able to fix the issue by moving the sass packages into the production dependencies instead of the devDependencies

I moved the two Sass packages to dependencies, and it worked:

   "dependencies": {
     "@rails/actioncable": "^6.0.0",
     "@rails/activestorage": "^6.0.0",
     "@rails/ujs": "^6.0.0",
     "@rails/webpacker": "^4.0.2",
     "turbolinks": "^5.2.0",
+ "node-sass": "^4.12.0",
+ "sass-loader": "^7.1.0"
   },
   "devDependencies": {
- "node-sass": "^4.12.0",
- "sass-loader": "^7.1.0",
     "webpack-dev-server": "^3.3.1"
   },

This winds up being a better solution because:

  1. It doesnโ€™t rerun the yarn install (which can take a while, even if it is supposed to be fast on subsuquent runs)
  2. Uses the libraries I expected
  3. Works with the default Heroku buildpack

Thanks to Brian and Jake for helping me get this sorted. Still a learning process with NPM, Webpack, and friends.

Top comments (0)