forked from emberjs-addons/ember-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assetfile
117 lines (99 loc) · 2.77 KB
/
Assetfile
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Encoding.default_external = "UTF-8" if defined?(Encoding)
require "rake-pipeline-web-filters"
require "json"
require "uglifier"
class EmberProductionFilter < Rake::Pipeline::Filter
def generate_output(inputs, output)
inputs.each do |input|
result = File.read(input.fullpath)
result.gsub!(%r{^(\s)*Ember\.(assert|deprecate|warn)\((.*)\).*$}, "")
output.write result
end
end
end
class EmberLicenseFilter < Rake::Pipeline::Filter
def generate_output(inputs, output)
inputs.each do |input|
file = File.read(input.fullpath)
license = File.read("generators/license.js")
output.write "#{license}\n\n#{file}"
end
end
end
class JSHintRC < Rake::Pipeline::Filter
def generate_output(inputs, output)
inputs.each do |input|
file = File.read(input.fullpath)
jshintrc = File.read(".jshintrc")
output.write "var JSHINTRC = #{jshintrc};\n\n#{file}"
end
end
end
distros = {
:full => %w(ember-bootstrap)
}
output "dist"
input "packages" do
output "tests"
match "*/tests/**/*.js" do
minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id.sub!('/tests', '/~tests')
id
}
concat "ember-bootstrap-tests.js"
end
match "ember-bootstrap-tests.js" do
filter JSHintRC
end
end
input "packages" do
match "*/lib/**/*.js" do
minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!('/lib/', '/')
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id
}
concat "ember-bootstrap-spade.js"
end
end
input "packages" do
match "*/lib/**/main.js" do
neuter(
:additional_dependencies => proc { |input|
Dir.glob(File.join(File.dirname(input.fullpath),'**','*.js'))
},
:path_transform => proc { |path, input|
package, path = path.split('/', 2)
current_package = input.path.split('/', 2)[0]
current_package == package && path ? File.join(package, "lib", "#{path}.js") : nil
},
:closure_wrap => true
) do |filename|
File.join("modules/", filename.gsub('/lib/main.js', '.js'))
end
end
end
distros.each do |name, modules|
name = "ember-bootstrap"
input "dist/modules" do
module_paths = modules.map{|m| "#{m}.js" }
match "{#{module_paths.join(',')}}" do
concat(module_paths){ ["#{name}.js", "#{name}.prod.js"] }
end
# Strip dev code
match "#{name}.prod.js" do
filter(EmberProductionFilter) { ["#{name}.prod.js", "#{name}.min.js"] }
end
# Minify
match "#{name}.min.js" do
uglify{ "#{name}.min.js" }
filter EmberLicenseFilter
end
end
end
# vim: filetype=ruby