Adriano Resende
Adriano Resende

Reputation: 2619

How to precompile assets without subfolder specific?

How precompile assets without subfolder specific?

Example, my assets is that way:

app/assets
    /fonts
    /images
        sprite.png
        /sprite
            icon1.png
            icon2.png
            ...
            iconX.png
    /stylesheets
    /javascripts

How I configure assets to precompile without folder /sprite in imagem ?

Upvotes: 0

Views: 71

Answers (1)

Philip Hallstrom
Philip Hallstrom

Reputation: 19899

A year ago this worked for me. I no longer do it, but I don't know why it wouldn't continue to work. Put this into config/application.rb (or config/initializers/assets.rb):

config.assets.precompile = [
  lambda do |filename, path|
    path =~ /app\/assets/ && 
    !%w(.js .css).include?(File.extname(filename)) &&
    path !~ %r{app/assets/images/sprite/}
  end,
  /(?:\/|\\|\A)application\.(css|js)$/
]

You may want to update the above to better match what's in the source below. Looks like it's changed a little bit, but this should get you where you need to go.

See https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L61

Upvotes: 2

Related Questions