-
Notifications
You must be signed in to change notification settings - Fork 188
/
Rakefile
31 lines (26 loc) · 830 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require "tempfile"
require "yui/compressor"
require "fileutils"
require "sprockets"
APP_PATH = File.expand_path("./public/application.js")
CLIENT_PATH = File.expand_path("./client.js")
task :build do
env = Sprockets::Environment.new
env.append_path 'client/vendor/assets/javascripts'
File.open(APP_PATH, 'w') { |f| f << env['juggernaut.js'].to_s }
File.open(CLIENT_PATH, 'w') { |f| f << env['juggernaut.js'].to_s }
end
task :compress do
tempfile = Tempfile.new("yui")
compressor = YUI::JavaScriptCompressor.new(:munge => true)
File.open(APP_PATH, "r") do |file|
compressor.compress(file) do |compressed|
while buffer = compressed.read(4096)
tempfile.write(buffer)
end
end
end
tempfile.close
FileUtils.mv(tempfile.path, APP_PATH)
end
task :default => [:build, :compress]