forked from huboard/huboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile
81 lines (70 loc) · 2.18 KB
/
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
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
require 'sass'
require 'bourbon'
require "#{File.join(File.dirname(__FILE__),"public/css/scss/bourbon/lib/bourbon/sass_extensions.rb")}"
desc "rebuild css files"
task :css do
Dir.glob("**/s{a,c}ss") { |d| Sass.load_paths << d }
Dir.glob("**/s{a,c}ss") do |d|
Dir.glob("#{d}/**/*.s[ac]ss").reject {|x| File.basename(x).start_with?"_"}.each do |sass|
cssfile = "#{d}/../#{File.basename(sass,".*")}.min.css"
Sass.compile_file sass, cssfile, {style: :compressed }
end
end
end
desc "rebuild js files"
task :js do
Dir.glob("**/[sS]cripts").each do |d|
Dir.glob("#{d}/**/*.slicer") do |slicer|
sh "echo #{slicer}"
#sh "node calfslicer.js #{slicer} ./#{d} #{d}/#{File.basename(slicer, ".*")}.js"
`sh ./calfslicer #{d} #{slicer} #{d}/#{File.basename(slicer,".*")}.js`
end
end
end
desc "compile require modules"
task :rjs do
class RequireModules
def initialize
@files = Dir.glob("**/[sS]cripts/modules/**/main.js")
end
def modules
@files.map do |f|
"#{File.dirname(f).gsub(/.*modules\//,"")}/#{File.basename(f,".js")}"
end
end
def baseUrl
File.dirname(@files[0]).gsub(/modules\/.*/,"modules")
end
def template
erb_template = %{
var config = {
name:"marker",
include: <%= modules %>,
exclude: ["socket"],
baseUrl: "<%= baseUrl %>",
out : "<%= baseUrl %>/huboard.allmodules.js"
}
console.log("config",config)
var requirejs = require("requirejs")
console.log("config",requirejs)
requirejs.optimize(config, function(contents){
console.log(contents);
}, function(err) {
console.log(err)
});
}
erb = ERB.new erb_template
erb.result binding
end
end
modules = RequireModules.new
config = modules.template
File.open("app.build.js","wb") { |f|
f.write config
}
sh "node app.build.js"
end
desc "precomile assets"
namespace :assets do
task :precompile => [:css]
end