I am in the process of upgrading my company’s Rails 6 app to Rails 7 and I’ve run into a
webpack issue when attempting to deploy this app to Heroku.
webpack is being run as documented here. When this app is deployed to Heroku as a Rails 6 app, this “just works”. Specifically, when looking at the Heroku build log for the deployment, I see
yarn install as part of
rake assets:precompile. This allows
webpack to work.
After upgrading to Rails 7, something has changed with regards to being able to run the
webpack command during
rake assets:precompile because during the Heroku deployment, I am now seeing this and I am not seeing
yarn install being run:
-----> Installing node-v16.13.1-linux-x64 -----> Installing yarn-v1.22.17 -----> Detecting rake tasks -----> Preparing app for Rails asset pipeline <lots of output> Compiling... Compilation failed: yarn run v1.22.17 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command "webpack" not found. ! ! Precompiling assets failed.
I ran into an identical issue during my CI on GitHub and I was able to work around this by adding a
yarn install step just before the
rake assets:precompile but this seems like a hack to me.
There is probably a “Rails 7” way to fix this such that the
webpack command is available prior to running
Any/all suggestions are welcome!