js-routes
js-routes copied to clipboard
Rails engine support: Engine configurations impact the main app
Hi,
First of all, thank you for this amazing gem. I have been using it for a while and it works very well!
I'm writting a Ruby on Rails gem (Rails Engine) that is meant to be installed in many applications.
My gem provides a built in administration written in Svelte and I use js-routes to handle my routing.
An issue that I am currently facing is that my Engine needs this configuration:
JsRoutes.setup do |c|
c.application = My::Engine
c.file = Rcf::Engine.root.join("app/frontend/rails/routes.js")
end
As soon as I install my gem in an app that also uses JsRoutes, I need to explicitly define
c.application = Rails.application
even if it is the default settings because the gem inself overrides this configuration.
Note: The gem comes with already pre-built javascript/css assets bundled with ruby-vite so the JsRoutes configuration really no longer matter to the gem in an application.
It would be great if instead of having like a "Global" configuration we could have kind of an "Instance" configuration per engine