How to use without Sprockets?
sedubois opened this issue · 4 comments
Hi! I wished to try out this gem but at installation I encounter this error:
% rails spina:install
rails aborted!
Sprockets::Railtie::ManifestNeededError: Expected to find a manifest file in `app/assets/config/manifest.js`
But did not, please create this file and use it to link any assets that need
to be rendered by your app:
Example:
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
and restart your server
For more information see: https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs
/Users/sdubois/Repos/yoga-dunky/config/environment.rb:5:in `<main>'
Tasks: TOP => spina:install => environment
(See full trace by running task with --trace)
This is on a fresh Rails 7.0.5 app generated with --asset-pipeline=propshaft
, i.e. Sprockets is not available. How to install Spina when using Propshaft?
Thanks a lot for your help.
Hey! I think I might be you from several days in the future... or maybe you're me in the past?
I'm a Spina-newbie who recently tried to embed Spina into a new Rails app using propshaft and, when I got the error you see, I just stupidly made a manifest.js
file, and somehow it worked! Like, I actually deployed to production and everything seemed to work fine... except I got one random 5xx error that appeared to be an exception about sassc
missing coming up from an ActiveJob instance... 😨
My app doesn't have much functionality yet, so I didn't get that my app was loading both propshaft and sprockets simultaneously, which is clearly not a good thing to do. Once I realized what was happening, I cloned the Spina repo to see if I could hack it into doing what Avo does, where all the assets are bundled into gem and served with Rack::Static.
After several hours, eventually I gave up... but while trying to figure out how to do it, I wound up re-reading Introducing Propshaft where DHH says (emphasis mine):
The biggest hurdle is likely to be that many gems are written to depend on Sprockets offering everything from CoffeeScript to Sass compilation out of the box. Those gems will need to be updated or we'll need to find ways of offering backwards compatibility. This isn't a quick migration, and there's no prospect of considering Propshaft as the new default until Rails 8.
That made me more comfortable with swapping out propshaft for sprockets (which made Spina happy) and then I followed this guide to set up importmaps-rails and dartsass-rails and completely eliminated Node.js from my setup, which is what I thought rails new ----asset-pipeline=propshaft
was going to do in the first place.
tl;dr I just tried making Spina work with propshaft and I don't see a way that doesn't involve significant changes to Spina.
I realize your situation may be vastly different than mine, and propshaft may be necessary for your use case. But once I saw your question I figured I should share my experience just in case you're in a similar situation.
Thank you so much @benzado for the thoughtful and helpful response. I'm in a similar situation setting up and testing Spina for a new project, and I thought I might as well use Propshaft as it's touted as the replacement for Sprockets, but if there are blockers I will revert to Sprockets.
I will leave this issue open at least to draw attention to the fact that Spina will need to get updated if/when Propshaft becomes the default Rails asset pipeline. It might also interest others meanwhile to be warned in the docs that Spina is incompatible with Propshaft.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
FWIW, I'm very much open to Propshaft support in Spina ✌️