inline_svg icon indicating copy to clipboard operation
inline_svg copied to clipboard

Add some documentation around configuring asset finders

Open mjankowski opened this issue 2 years ago • 5 comments

I was attempting to use propshaft on a Rails 7 app, and based on https://github.com/jamesmartin/inline_svg/pull/134 I assumed (incorrectly) that inline_svg would "just work" within that setup, but I think it needs to be explicitly configured to use Propshaft.

If that's correct, this is an attempt to improve the docs in that regard. If not, I must have something wrong locally.

mjankowski avatar Feb 09 '22 20:02 mjankowski

@mjankowski thanks for opening this PR! ✨

I assumed (incorrectly) that inline_svg would "just work" within that setup, but I think it needs to be explicitly configured to use Propshaft.

That's interesting. I use a basic Rails 7 test App for the automated integration testing on this gem, and that seems to work out of the box. That App is not explicitly configured to use PropShaft though. I wonder if that's why it seems to work. 🤔

jamesmartin avatar Feb 09 '22 21:02 jamesmartin

Yeah - I believe you need to explicitly turn on propshaft either via a generator config option on a freshly generated app, or by adding the propshaft gem and removing sprockets if you are upgrading an old app. So, I suspect that your test app is successfully testing rails 7 integration, but not propshaft integration, if that makes sense (sprockets still works on 7).

mjankowski avatar Feb 09 '22 21:02 mjankowski

Thanks for the feedback, I'll update the test App so we have a Rails 7 with and without Sprockets.

Regarding this gem's compatibility with Rails 7, it feels like we should be able to "detect" whether Sprockets or Propshaft is in use and configure the asset finder accordingly.

jamesmartin avatar Feb 11 '22 00:02 jamesmartin

Yeah - I think you probably could detect it. That's what I assumed would be happening.

I could see any of these working...

  • Look for the presence of certain gems being loaded or not, choose based on that
  • Look for presence of certain ruby classes being present, choose based on that
  • Some sort of conditional matrix of rails versions and gem/class presence

In those scenarios you'd need to have some default behavior to fall back on when multiple gems/classes/whatever were present. For example, a rails app which has Sprockets and Propshaft and Webpacker all present at the same time.

mjankowski avatar Feb 11 '22 14:02 mjankowski

I ran into the same issue. https://github.com/jamesmartin/inline_svg/issues/151

xymbol avatar Oct 12 '23 13:10 xymbol