Webpacker not interpolating the environment correctly to get to the right config file for the environment

Viewed 84

We recently upgraded webpacker in our project. Now when I deploy with capistrano, I get a compilation error like:

webpack config /path/to/project/releases/20210617155029/config/webpack/.js not found, please run 'bundle exec rails webpacker:install' to install Webpacker with default configs or add the missing config file for your custom environment.

The obvious issue here is that webpacker is not looking for the correct config file, which should be config/webpack/staging.js in this case because I am deploying to the staging environment.

If I try to deploy again after such a failed attempt, it compiles just fine. It is as though whatever webpacker uses to determine the deployment environment is not set until a failed deploy happens. Does anyone know how webpacker determines the rails environment?

0 Answers
Related