forked from jzajpt/em-analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assetfile
135 lines (116 loc) · 2.97 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
128
129
130
131
132
133
134
135
APPNAME = 'ember-analytics'
require 'json'
require 'rake-pipeline-web-filters'
WebFilters = Rake::Pipeline::Web::Filters
class LoaderFilter < WebFilters::MinispadeFilter
def generate_output(inputs, output)
inputs.each do |input|
code = input.read
module_id = @module_id_generator.call(input)
contents = "function(require) {\n#{code}\n}"
ret = "\nloader.register('#{module_id}', #{contents});\n"
output.write ret
end
end
end
class EmberAssertFilter < Filter
def generate_output(inputs, output)
inputs.each do |input|
result = input.read
result.gsub!(/ember_assert\((.*)\);/, '')
output.write(result)
end
end
end
class HandlebarsFilter < Filter
def generate_output(inputs, output)
inputs.each do |input|
code = input.read.to_json
name = File.basename(input.path, '.handlebars')
output.write "\nreturn Ember.Handlebars.compile(#{code});\n"
end
end
end
output 'assets'
input 'app' do
match 'lib/**/*.js' do
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^lib\//, "#{APPNAME}/").sub(/\.js$/, '')
}
if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat 'app.js'
end
match '*.coffee' do
filter Rake::Pipeline::Web::Filters::CoffeeScriptFilter
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^lib\//, "#{APPNAME}/").sub(/\.js$/, '')
}
concat 'app.js'
end
match 'vendor/**/*.js' do
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^vendor\//, '').sub(/\.js$/, '')
}
if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat %w[
vendor/jquery.js
vendor/ember.js
vendor/ember-data.js
vendor/sproutcore-routing.js
], 'app.js'
end
match 'modules/**/*.js' do
if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat 'app.js'
end
match 'plugins/**/*.js' do
if ENV['RAKEP_MODE'] == 'production'
uglify {|input| input}
end
concat do |input|
input.sub(/plugins\//, '')
end
end
match 'templates/**/*.handlebars' do
filter HandlebarsFilter
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^templates\//, "#{APPNAME}/~templates/").sub(/\.handlebars$/, '')
}
if ENV['RAKEP_MODE'] == 'production'
uglify {|input| input}
end
concat 'app.js'
end
match 'css/**/*.css' do
if ENV['RAKEP_MODE'] == 'production'
yui_css
end
concat ['bootstrap.css', 'main.css'], 'app.css'
end
match 'css/**/*.scss' do
sass
if ENV['RAKEP_MODE'] == 'production'
yui_css
end
concat 'app.css'
end
match "static/**/*" do
concat do |input|
input.sub(/static\//, '')
end
end
end
# vim: filetype=ruby