Created
March 8, 2013 23:21
-
-
Save lg/5120914 to your computer and use it in GitHub Desktop.
Force files to be precompiled by the Rails 3 asset pipeline via instructions in _precompile.js and _precompile.css. Add this to config/environments/production.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| get_requires_from_file = Proc.new do |filename| | |
| files = Sprockets::DirectiveProcessor.new(filename).directives.collect { |f| f[1] == "require" ? f[2] : nil }.compact | |
| files.collect do |file| | |
| search_path = File.join(File.dirname(filename), file) | |
| files = Dir.glob("#{search_path}.*") | |
| files.collect { |f| File.basename(f) } | |
| end.flatten | |
| end | |
| config.assets.precompile += | |
| get_requires_from_file.call("app/assets/javascripts/_precompile.js") + | |
| get_requires_from_file.call("app/assets/stylesheets/_precompile.css") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment