I’ve configured webpacker to be able to process ERBs (bundle exec rails webpacker:install:erb) because I need paths generated by Sprockets' asset_p...
For further actions, you may consider blocking this person and/or reporting abuse
What about this? github.com/rails/webpacker/blob/ma...
You beat me to it 😉I was about to comment it but refreshed first and saw your comment.
I tried this earlier today and it did not seem to work. Maybe I had something misconfigured. Will give it another go. Thanks @rhymes !
Oh snap! It works now. Must have been a case of not enough coffee. Thanks peeps!
May anyone who lands on this thread during a future search rejoice!
@rhymes , @ben , I figured out why it wasn't working the other day because it wasn't working for me today either. This is probably obvious to seasoned Rails devs, but this wasn't obvious to a Rails newb like me. 🙃
This is the sample code from the webpacker docs
I didn't realize that Sprockets checks to see if the image actually exists, i.e.
'rails.png'
. This is why I was getting exit code 1 from the rails-erb-loader.I discovered this by reading through one of the issues about exit code 1 for rails-erb-loader.
I followed the instructions from n-rodriguez to test it outside of the rails-erb-loader, so I ran
and sure enough, I got an error but with more details.
Sprockets::Rails::Helper::AssetNotFound
.So TIL that Sprockets actually looks for the asset. It just isn't trying to create a URL for any random image.
Remember folks, always dig when things aren't working 😉