Skip to content

Issue loading images from dfm_web manifest.js in Rails 6 with Webpacker #88

Description

@yengfinity

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:

Screen Shot 2021-12-04 at 1 36 06 PM

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:

  1. Covert all the engine's assets to the webpacker environment (loading them via the javascript/pack)
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions