Trouble Utilizing Webpacker for JS in Gem Development

Hello all! First time poster here. I am trying to develop a custom rails gem and I’m having a harder than expected time understanding how to utilize Webpacker in the dummy app. It appears that this is not supported yet? Suggestions on how to include JS when doing custom gem development?

I’ll go ahead and respond here. I think my issue is that I was only using a “gemified plugin” as opposed to an engine. I see that I can utilize Webpacker when passing the mountable flag:

rails plugin new gem_name --mountable

The Edge Guides Webpacker — Ruby on Rails Guides suggest that you may want to distribute your non-ruby assets in an NPM module, and add instructions or an installer hook to your gem to get them added to the parent application. I’m hoping this is just a stop-gap along the way to a more robust solution. We’ve been so spoiled by the maturity of the Sprockets system for so long.


1 Like