Created
November 6, 2012 21:11
-
-
Save nilclass/4027582 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
diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake | |
index 4c9b90c..faff2dd 100644 | |
--- a/lib/tasks/assets.rake | |
+++ b/lib/tasks/assets.rake | |
@@ -16,6 +16,7 @@ begin | |
require "jsmin" | |
require "./config/directories" | |
+ | |
def clean_dir(dir) | |
Dir.glob(dir + '/*').each do |filename| | |
File.unlink(filename) if File.exists?(filename) && !File.directory?(filename) | |
@@ -41,28 +42,15 @@ begin | |
namespace :cg do | |
desc "compile the javascript for deployment" | |
task :compile_assets => :clean_assets do | |
- environment = Sprockets::Environment.new | |
- environment.append_path asset_dir | |
- FileUtils.mkdir_p(output_dir) | |
- input_files.each do |file| | |
- filename = output_dir + '/' + file | |
- File.open(filename, 'w') do |f| | |
- f.write(JSMin.minify(environment[file].to_s)) | |
- end | |
- if gzip | |
- `gzip --stdout #{filename} > #{filename}.gz` | |
- end | |
- end | |
+ render_dir(STATIC_JS_SRC_DIR, STATIC_JS_DEST_DIR) | |
end | |
desc "remove the compiled static assets" | |
task :clean_assets do | |
- Dir.glob(output_dir + '/*').each do |filename| | |
- File.unlink(filename) if File.exists?(filename) | |
- end | |
+ clean_dir(STATIC_JS_DEST_DIR) | |
end | |
end | |
rescue LoadError => exc | |
- # silently skip this rake task | |
+ puts "(cg:compile_assets not available, make sure you have jsmin and sprockets gems installed)" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment