Created
April 19, 2010 15:00
-
-
Save brandonaaron/371124 to your computer and use it in GitHub Desktop.
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
# override the write_asset_file_contents so that it will minify js in production via jsmin.rb | |
module ActionView | |
module Helpers | |
module AssetTagHelper | |
alias_method :write_asset_file_contents_stock, :write_asset_file_contents | |
def write_asset_file_contents(joined_asset_path, asset_paths) | |
ret = write_asset_file_contents_stock(joined_asset_path, asset_paths) | |
if File.extname(joined_asset_path) == ".js" | |
tmp_path = "#{RAILS_ROOT}/tmp/asset_combined.js" | |
FileUtils.cp(joined_asset_path, tmp_path) | |
File.open(tmp_path, 'r') do |tmp| | |
File.open(joined_asset_path, 'w') { |file| file.write(JSMin.minify(tmp)) } | |
end | |
FileUtils.rm(tmp_path) | |
end | |
ret | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment