Editing .slugignore does not work there, because file exclusion begins before all stages of compilation on Heroku. But we need to compile them all, move them to S3, and only then delete them.
I wrote the code in my Rakefile, a small script that deletes all unusable files using the extension filter:
Rake::Task["assets:precompile"].enhance do puts 'my assets:precompile hook is started!' dir_path = "#{Dir.pwd}/public/sites-fromfuture-net/" records = Dir.glob("#{dir_path}**/*") records.each do |f| if f =~ /.*.png$/ or f =~ /.*.jpg$/ or f =~ /.*.eot$/ or f =~ /.*.svg$/ or f =~ /.*.woff$/ or f =~ /.*.ttf$/ or f =~ /.*.otf$/ or f =~ /.*.css$/ or f =~ /.*.js$/ or f =~ /.*.wav$/ then File.delete(f) end end
And one more thing: I use the hero of the deflater hero, who gzips all css and js assets, so I delete all the .css and .js script files, but I do not delete .css.gz and .js.gz, due to check rail resources.
source share