forked from jashkenas/underscore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
27 lines (24 loc) · 873 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
require 'rubygems'
require 'closure-compiler'
desc "Use the Closure Compiler to compress Underscore.js"
task :build do
js = File.open('underscore.js', 'r')
min = Closure::Compiler.new.compile(js)
File.open('underscore-min.js', 'w') {|f| f.write(min) }
end
task :build_advanced do
js = File.read('underscore.js')
# remove wrapping anonymous function as this messes with closure compiler
# see
# http://groups.google.com/group/closure-compiler-discuss/browse_thread/thread/b59b54c1a0073aa5
js.sub!('(function() {', '').chomp!("})();\n")
compiler = Closure::Compiler.new \
:compilation_level => 'ADVANCED_OPTIMIZATIONS',
:formatting => 'PRETTY_PRINT'
min = compiler.compile(js)
File.open('underscore-min2.js', 'w') {|f| f.write(min) }
#
original_size = js.length
minimized_size = min.length
puts original_size, minimized_size
end