Miha Rekar bio photo

Miha Rekar

πŸ‘¨β€πŸ’» Software Developer
πŸŽ™οΈ Podcaster
πŸ•΄ International Speaker
πŸ‘¨β€πŸ« RubySlovenia organizer
β˜•οΈ Home Barista
πŸƒ Marathon Runner
πŸ“· Event Photographer
πŸ“– Aspiring Stoic
πŸ¦„ Special

Email Twitter Github Facebook LinkedIn Instagram Stackoverflow Speaker Deck Foursquare Youtube Soundcloud

I’ve spent a good hour debugging why the .svg file from my swipebox gem wasn’t being precompiled by the Rails Asset Pipeline. I’m still not sure why, because it works with .svg fonts but for some reason it didn’t want to β€œgrab” the swipebox-icons.svg file.

The way I solved is I added an initializer to my Engine class which adds all the images (just in case) to the config.assets.precompile setting:

module Swipebox
  class Engine < ::Rails::Engine
    initializer 'swipebox.assets.precompile' do |app|
      app.config.assets.precompile << %r(swipebox-[\w]+\.(?:png|svg|gif)$)
    end
  end
end

Hope it helps someone :)