You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the release of Rails 8 and new apps having Propshaft instead of Sprockets, How are Rails engines being made to work for both styles? For example many gems contains a Web UI which is a Rails engine.
So far whats been suggested is using /public for assets and using CDN script/link tags for external assets. This is mostly an approach I have already been using.
Im hoping there should be a better story than this.
So far this is the only sprockets configuration that may be relevant to this conversation. Just including it here for completeness.
Propshaft doesn't use config.assets.precompile at all, it adds asset folders from gems to the load path and assumes the folder structure conventions are followed.
If you're not using vanilla CSS and Javascript, and you need to precompile from Sass or some other language supported in Sprockets, some options you have for now are either:
Precompile assets into app/assets/builds for the gem as part of the workflow to publish the gem - propshaft will be able to use these assets
Add a Gem.post_install hook that runs the precompilation for the gem
Option 1 should work fine for gems installed from Rubygems, but I assume you don't want to push your build artifacts to Github, so any gems installed with git will not have the prebuilt assets.
Option 2 should work for both scenarios, but will probably require the consumer to install more runtime dependencies.
builds folders should be given higher priority in the load path, so any asset that is precompiled and named the same in two locations will be served as the builds variant.
Now that Propshaft is stable, and Rails 8 is release, I can write some documentation for gem authors that wants to add support for Propshaft.
With the release of Rails 8 and new apps having Propshaft instead of Sprockets, How are Rails engines being made to work for both styles? For example many gems contains a Web UI which is a Rails engine.
So far whats been suggested is using
/public
for assets and using CDN script/link tags for external assets. This is mostly an approach I have already been using.Im hoping there should be a better story than this.
So far this is the only sprockets configuration that may be relevant to this conversation. Just including it here for completeness.
Also posted this question to reddit: https://www.reddit.com/r/rails/comments/1gtin65/how_can_a_rails_engine_be_adapted_to_support_both/
The text was updated successfully, but these errors were encountered: