This repository has been archived by the owner on Mar 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Assetfile
127 lines (96 loc) · 2.6 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
118
119
120
121
122
123
124
125
126
127
require "rake-pipeline-web-filters"
require "json"
require "uglifier"
require "execjs"
class HandlebarsFilter < Rake::Pipeline::Filter
def initialize(&block)
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') }
super(&block)
end
def generate_output(inputs, output)
inputs.each do |input|
name = File.basename(input.path, '.handlebars')
output.write "Ember.TEMPLATES['#{name}'] = Ember.Handlebars.compile(#{input.read.to_json});\n"
end
end
end
class AddMicroLoaderFilter < Rake::Pipeline::Filter
LOADER = File.expand_path("../app/submodules/ember.js/packages/loader/lib/main.js", __FILE__)
def initialize(options={}, &block)
super(&block)
@global = options[:global]
end
def generate_output(inputs, output)
output.write "(function() {\n" unless @global
output.write File.read(LOADER)
inputs.each do |input|
output.write input.read
end
output.write "\n})();\n" unless @global
end
def additional_dependencies(input)
[ LOADER ]
end
end
output "public/source"
input "app" do
match "styles/public/*.css" do
concat "app.css"
end
match "styles/common/*.css" do
concat "app.css"
end
match "styles/externals/*.css" do
concat "app.css"
end
match "templates/**/*.handlebars" do
filter HandlebarsFilter
minispade :rewrite_requires => true, :string=> false, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!(/\.js$/, '')
id
}
filter ConcatFilter, "app.js"
end
match "app/lib/**/*.js" do
minispade :rewrite_requires => true, :string=> false, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!('/lib/', '/')
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id
}
concat "app.js"
end
match "submodules/ember-touch/packages/ember-touch/lib/**/.js" do
minispade :rewrite_requires => true, :string=> false, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!('submodules/', '')
id.sub!(/[a-z\-\.]+\//, '')
id.sub!('packages/', '')
id.sub!('/lib/', '/')
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id
}
concat "app.js"
end
match "submodules/ember.js/packages/*/lib/**/.js" do
minispade :rewrite_requires => true, :string=> false, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!('submodules/', '')
id.sub!(/[a-z\-\.]+\//, '')
id.sub!('packages/', '')
id.sub!('/lib/', '/')
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id
}
concat "app.js"
filter AddMicroLoaderFilter, :global => true
end
match "vendor/*" do
filter ConcatFilter, "app.js"
end
end
# vim: filetype=ruby