It seems like rails engines is still the forgotten child of the Rails 6 with Webpacker. After I installed and ran my app as host (rails 6 with default Webpacker), I encountered this issue after adding dfm_web's gem and followed the installation directions:

This makes sense because the _nav.html.erb parital is trying to load the uwcrest.png image from the engine and can't load any assets to the host app. To fix this at the moment and probably the fastest way for now, I added what the error message suggested to the host app's manifest.js file:
//= link dfm_web/uwcrest.png
This is redundant because that is what the engine's manifest.js file is suppose to do, however webpacker doesn't want to play nice at the moment like Jacob mentioned here: #74 . There are a few ways that this can be handled at the moment but probably not the best being that we don't know where webpacker/sprocket is taking us:
- Covert all the engine's assets to the webpacker environment (loading them via the javascript/pack)
- Add webpacker to the engine where it'll generate public assets that'll work nicely with webpacker and load them on the host side.
I feel that Webpacker only makes sense for front-end heavy applications (i.e React, Angular, Vue...) which require a lot of javascript and not so much css/images. So being that the engine only have one javascript file, the first choice is off the table. Choice number two is good for now to have a good mix of sprocket and webpacker, but it requires more changes to the engine.
The host app is running on Rails 6.1.4.1, Ruby 2.7.4, Sprocket 4.0.2 and Webpacker 5.4.3
It seems like rails engines is still the forgotten child of the Rails 6 with Webpacker. After I installed and ran my app as host (rails 6 with default Webpacker), I encountered this issue after adding dfm_web's gem and followed the installation directions:
This makes sense because the
_nav.html.erb paritalis trying to load theuwcrest.pngimage from the engine and can't load any assets to the host app. To fix this at the moment and probably the fastest way for now, I added what the error message suggested to the host app's manifest.js file:This is redundant because that is what the engine's manifest.js file is suppose to do, however webpacker doesn't want to play nice at the moment like Jacob mentioned here: #74 . There are a few ways that this can be handled at the moment but probably not the best being that we don't know where webpacker/sprocket is taking us:
I feel that Webpacker only makes sense for front-end heavy applications (i.e React, Angular, Vue...) which require a lot of javascript and not so much css/images. So being that the engine only have one javascript file, the first choice is off the table. Choice number two is good for now to have a good mix of sprocket and webpacker, but it requires more changes to the engine.
The host app is running on Rails 6.1.4.1, Ruby 2.7.4, Sprocket 4.0.2 and Webpacker 5.4.3