What is the best way to use webpacker in a Rails engine?

I understand that there is some debate about using webpacker in Rails machines, but I have a simple utility and there is currently a workaround. I would like to know about the best (best?) Solution.

In this rails engine, I have a webpacker setting in the "spec / dummy" directory, and everything works fine in dev: https://github.com/RealEstateWebTools/property_web_scraper/tree/master/spec/dummy/config/webpack

When the engine is used by the rails application, it will not find the compiled webpack files, so every time I have a ready release, I collect the webpack files and manually copy them to the vendor directory: https://github.com/RealEstateWebTools/property_web_scraper/tree/ master / vendor / assets / javascripts

Then I require this file here: https://github.com/RealEstateWebTools/property_web_scraper/blob/master/app/assets/javascripts/property_web_scraper/spp_vuetify.js

In my layout, I use the above file using the good old "javascript_include_tag" stars: https://github.com/RealEstateWebTools/property_web_scraper/blob/master/app/views/layouts/property_web_scraper/spp_vuetify.html

There is a check in the layout to make sure that I run the spec / dummy application, in which case I will use the user's webpacker, as it will usually be used in dev.

There must be a better way than this.

+4
source share

Source: https://habr.com/ru/post/1690995/


All Articles