forked from evolvingweb/ajax-solr
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
44 lines (36 loc) · 1009 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
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'rake'
require 'yui/compressor'
desc 'Aggregate all javascript files'
task :aggregate, :compress do |t, args|
args.with_defaults(:compress => false)
output_file = ENV['output'] || 'ajax-solr.min.js'
core = [
'Core',
'AbstractManager',
'ParameterStore',
'Parameter',
'AbstractWidget',
'AbstractFacetWidget'
]
dirs = [
'core',
'helpers',
'managers',
'widgets'
]
compressor = YUI::JavaScriptCompressor.new(:munge => true) if args[:compress]
files = core.map{ |name| "core/#{name}.js" } + dirs.map{ |dir| Dir["#{dir}/**/*.js"] }.flatten
files.uniq!
action = args[:compress] ? "Compressing" : "Aggregating"
File.open(output_file, 'w') do |output|
files.each do |file_name|
puts "#{action} #{file_name}"
input = File.read(file_name)
output.write(args[:compress] ? compressor.compress(input) : input)
end
end
end
desc 'Compress all javascript files'
task :compress do
Rake::Task[:aggregate].invoke(true)
end