All threads / Using webpacker in Rails Engines?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Using webpacker in Rails Engines?

Johan André asked in Rails

I'm making a pluggable CMS engine and want to keep the JS/CSS (preferably by writing Tailwind components) in the engine. It works great with models, controllers, routes and the asset pipeline, but I really can't figure out the best way to do it with Webpacker-packs.

Any tips?

Hi Johan! Have you seen this issue? https://github.com/rails/webpacker/issues/348
Yes! Thank you! Basically it says that there is no good way (right now) to use webpacker in engines. :(
Hi Johan, I'm working on Webpacker engine integration for my company and we found a beautiful solution. You can use our generator to add webpacker support on the engine (for the development) and read the documentation to complete the integration of the engine on the main application with the assets compilation. Here is the link: https://github.com/ideonetwork/dakarai#engine-webpacker
Here there is also a description of how this method works and how it should be integrated on the Webpacker core (see the last post).
https://github.com/rails/webpacker/issues/348
Thanks Gregorio! Will check it out! 

It would be super cool if Chris could cover this. Nobody in that github issue thread has found an official answer to this, and the official README from the rails/webpacker repository just doesn't work as intended. At least not for me.

This is something I've been struggling with for a long time, and apparently so has a lot of other people. There are unanswered StackOverflow posts, unanswered reddit posts, and of course, that entire issue ticket which has ideas but no solutions. There are a few solutions, but they're hacky, and don't work for everyone

Even if the only good solution right now is hacky, that's probably enough for most peoples' needs until someone creates a good solution. I'd love to contribute, but I don't have enough rails and/or webpacker knowledge yet to do so.

This thread started on GoRails started about a year and half ago, and there still isn't a clear answer anywhere. There wasn't a clear answer in rails 5, and there still isn't an answer in rails 6, even with the now released stable version.

Again, it seems that way. If there is some article on the internet some where that explains how to have a rails 6 engine with webpacker that can either server compiled assets to the parent app, or let the parent app be responsible for compiling its own assets as well as all the engines assets to which it's connected, please point me to it.

Thanks,
Angel.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,344+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.