Closed Kukunin closed 2 years ago
Fortunately, it's possible 😃
Gem.loaded_specs['activeadmin_sortable_table'].full_gem_path
config/vite.rb
to set an environment variable with that path@activeadmin_sortable_table
using that environment variable@activeadmin_sortable_table
as neededSee this discussion for details, and feel free to share your particular setup in case it's useful for someone else.
Is your feature request related to a problem? Please describe. The problem is that we have a lot of gems relying on sprockets, and not everyone supports webpacker/vite_ruby approach. For example, activeadmin_sortable_table gem allows records to be re-ordered in ActiveAdmin. It provides both js and CSS file, but it can't be imported from the entrypoint directly.
Describe the solution you'd like It would be cool if it is possible to import assets from gem folders. So in my
app/frontend/entrypoints/activeadmin.js
I could doI assume that an automatic alias can be added that is resolved to the bundle gem folder. I added the
~
just to make a difference from node_modules. The prefix can be anything (@gems/
etc)Describe alternatives you've considered Currently, what I do is copy the assets to
app/frontend
and import them as usual. It's bad because once the dependent gem is updated, I need to copy assets one more time otherwise they will be outdated.Additional context