Created
March 9, 2012 07:21
-
-
Save markbrown4/2005437 to your computer and use it in GitHub Desktop.
Rake task for combining & compressing javascript files using Sprockets & uglifier
This file contains 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
assets = %w{application} | |
task :compile do | |
require 'sprockets' | |
environment = Sprockets::Environment.new(File.dirname(__FILE__)) | |
environment.append_path 'src/' | |
assets.each do |asset| | |
full_js = environment.find_asset(asset).to_s | |
require 'uglifier' | |
compressed_js = Uglifier.compile(full_js) | |
File.open('js/'+asset+'.js', 'w') do |f| | |
f.write(compressed_js) | |
end | |
end | |
end | |
task :default => :compile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment