Stimulus Discourse

Anybody had luck deploying to Heroku?


#1

I’ve a test Rails app with Stimulus installed running successfully locally, but I’m having trouble deploying it to Heroku. Do you have any advice in general on what I need look out for?

I’m getting this error:

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

This part of build seems relevant:

remote:        [3/5] Fetching packages...
remote:        info fsevents@1.2.4: The platform "linux" is incompatible with this module.
remote:        info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
remote:        [4/5] Linking dependencies...
remote:        warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697"
remote:        warning " > webpack-dev-server@2.11.2" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
remote:        warning "webpack-dev-server > webpack-dev-middleware@1.12.2" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
remote:        [5/5] Building fresh packages...
remote:        Done in 24.59s.
remote:        I, [2018-12-09T03:11:05.060948 #2441]  INFO -- : Writing /tmp/build_30ce1fff22e15a6dc5ae1d0bfbbd3991/public/assets/application-9622f0fe63bfad91bdeaa3a771e86262263840678fd66849b311b6cfb3f7cc85.js
remote:        I, [2018-12-09T03:11:05.061333 #2441]  INFO -- : Writing /tmp/build_30ce1fff22e15a6dc5ae1d0bfbbd3991/public/assets/application-9622f0fe63bfad91bdeaa3a771e86262263840678fd66849b311b6cfb3f7cc85.js.gz
remote:        I, [2018-12-09T03:11:05.073662 #2441]  INFO -- : Writing /tmp/build_30ce1fff22e15a6dc5ae1d0bfbbd3991/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css
remote:        I, [2018-12-09T03:11:05.073792 #2441]  INFO -- : Writing /tmp/build_30ce1fff22e15a6dc5ae1d0bfbbd3991/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css.gz
remote:        rake aborted!

#2

Our app runs on Heroku and I was able to deploy Stimulus out of the box. We use it together with webpacker.

To be honest, I don’t know what’s the issue in your case, but I would probably focus on this:

remote:        warning " > webpack-dev-server@2.11.2" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
remote:        warning "webpack-dev-server > webpack-dev-middleware@1.12.2" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".

#3

@iraszl
This is not realated to Stimulus but more to Webpack. Heroku doesn’t always build projects in the correct order. What usually solve this for me is to manually specify the build pack order on Heroku

$ heroku buildpacks:add --index 1 heroku/nodejs 
$ heroku buildpacks:add --index 2 heroku/ruby

#4

These are our buildpacks:

$ heroku buildpacks
=== app Buildpack URLs
1. heroku/ruby
2. https://github.com/heroku/heroku-buildpack-cli

The second one is unrelated to Rails or Stimulus, so heroku/ruby is enough for us.


#5

Thank you! I will do another fresh new test.


#6

does nodejs have to be first or it doesnt matter?


#7

In my case I had several project where I needed to specify the buildpack orders and Node/JS had to be the first one.
In some other project it would work out of the box. I wasn’t really able to understand why.
This is just something that I do now to avoid any deployment issue on Heroku.

But as pointed @mrhead, it looks like it is not always required