Create a gist now

Instantly share code, notes, and snippets.

Embed
config.assets.precompile
def compile_asset?(path)
# ignores any filename that begins with '_' (e.g. sass partials)
# all other css/js/sass/image files are processed
if File.basename(path) =~ /^[^_].*\.\w+$/
puts "Compiling: #{path}"
true
else
puts "Ignoring: #{path}"
false
end
end
config.assets.precompile = [ method(:compile_asset?).to_proc ]
@iwinux

This comment has been minimized.

Show comment
Hide comment
@iwinux

iwinux Dec 28, 2011

And since rake assets:precompile gives no indicator of the compilation progress, I think it great to print these Compiling and Ignoring lines.

Owner

iwinux commented Dec 28, 2011

And since rake assets:precompile gives no indicator of the compilation progress, I think it great to print these Compiling and Ignoring lines.

@wchrisjohnson

This comment has been minimized.

Show comment
Hide comment
@wchrisjohnson

wchrisjohnson Mar 15, 2012

Forgive the ignorance, but where would this method go? Inside the env file itself?

Forgive the ignorance, but where would this method go? Inside the env file itself?

@iwinux

This comment has been minimized.

Show comment
Hide comment
@iwinux

iwinux Mar 16, 2012

@cjohnson I put these into the production.rb

Owner

iwinux commented Mar 16, 2012

@cjohnson I put these into the production.rb

@bkempner

This comment has been minimized.

Show comment
Hide comment
@bkempner

bkempner Mar 29, 2012

Doesn't work for me at all when deploying on heroku. I pasted in my production.rb

2012-03-29T18:19:47+00:00 app[web.1]: /app/config/environments/production.rb:27:in method': undefined methodcompile_asset?' for class Class' (NameError) 2012-03-29T18:19:47+00:00 app[web.1]: from /app/config/environments/production.rb:27:inblock in <top (required)>'

Doesn't work for me at all when deploying on heroku. I pasted in my production.rb

2012-03-29T18:19:47+00:00 app[web.1]: /app/config/environments/production.rb:27:in method': undefined methodcompile_asset?' for class Class' (NameError) 2012-03-29T18:19:47+00:00 app[web.1]: from /app/config/environments/production.rb:27:inblock in <top (required)>'

@logical42

This comment has been minimized.

Show comment
Hide comment
@logical42

logical42 May 4, 2012

try putting the method in the outer scope:

 #the absolute beginning of the production.rb file
def compile_asset?(path)
  if File.basename(path) =~ /^[^_].*\.\w+$/
    puts "Compiling: #{path}"
    true
  else
    puts "Ignoring: #{path}"
    false
  end
end
SomeApplicationName::Application.configure do
   config.assets.precompile = [ method(:compile_asset?).to_proc ]
#...some other config stuff
end

try putting the method in the outer scope:

 #the absolute beginning of the production.rb file
def compile_asset?(path)
  if File.basename(path) =~ /^[^_].*\.\w+$/
    puts "Compiling: #{path}"
    true
  else
    puts "Ignoring: #{path}"
    false
  end
end
SomeApplicationName::Application.configure do
   config.assets.precompile = [ method(:compile_asset?).to_proc ]
#...some other config stuff
end
@swrobel

This comment has been minimized.

Show comment
Hide comment
@swrobel

swrobel Oct 26, 2012

Thank you! 👏

swrobel commented Oct 26, 2012

Thank you! 👏

@okliv

This comment has been minimized.

Show comment
Hide comment
@okliv

okliv Nov 9, 2013

just amazing!

okliv commented Nov 9, 2013

just amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment