× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Include files from gem into Asset Pipeline

Miha Rekar
Sep 13, 2014
<p>I've spent a good hour debugging why the <strong>.svg</strong> file from my <a href="https://github.com/mrfoto/swipebox">swipebox gem</a> wasn't being precompiled by the <strong>Rails Asset Pipeline</strong>. 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.</p><p>The way I solved is I added an <strong>initializer</strong> to my Engine class which adds all the images (just in case) to the <code>config.assets.precompile</code> setting:</p><pre><code>module Swipebox class Engine &lt; ::Rails::Engine initializer 'swipebox.assets.precompile' do |app| app.config.assets.precompile &lt;&lt; %r(swipebox-[\w]+\.(?:png|svg|gif)$) end end end </code></pre><p>Hope it helps someone :)</p>
comments powered by Disqus