jamesmartin/inline_svg

inline_svg + angular-rails-templates + in RAILS_ENV=production rake assets:precompile

Closed this issue · 2 comments

Opening an issue here related to pitr/angular-rails-templates#160 as I'm at a loss where the problem might be.

My issue is that when we RAILS_ENV=production rake assets:precompile it's not able to find any of the SVG files.

pitr/angular-rails-templates#79 enumerates how to configure inline_svg for angular-rails-templates

    config.assets.configure do |env|
      env.context_class.class_eval do
        include ApplicationHelper
        include ActionView::Helpers
        include Rails.application.routes.url_helpers
        include InlineSvg::ActionView::Helpers
      end
    end

This works in development but I think that's because it's dynamically compiling the assets with Sprockets at that point.

I added a binding.pry in the inline_svg method and noticed that rather than a Sprockets::Environment being the finder, it's falling back to InlineSvg:: StaticAssetFinder which is not finding any of the assets.

Any suggestions as to what we're missing? I don't think this is exactly the same issue as @JonaMX
mentions in #85 but I can potentially follow that route (not sure where Tilt plays into it but maybe?).

Any help would be greatly appreciated.

I should also note that we were using 1.2.6 of inline_svg...I bumped to 1.3.1 and it still doesn't seem to be working.

Closing this issue...I believe I've found a workaround, but definitely open to better suggestions. I

    config.assets.configure do |env|
      InlineSvg.configuration.asset_finder = env # => this seems to fix it

      env.context_class.class_eval do
        include ApplicationHelper
        include ActionView::Helpers
        include Rails.application.routes.url_helpers
        include InlineSvg::ActionView::Helpers
      end
    end