-
Notifications
You must be signed in to change notification settings - Fork 23
/
Rakefile
52 lines (38 loc) · 1.04 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
require "bundler/setup"
require "sproutcore"
require "erb"
require "uglifier"
LICENSE = File.read("generators/license.js")
def strip_require(file)
result = File.read(file)
result.gsub!(%r{^\s*require\(['"]([^'"])*['"]\);?\s*$}, "")
result
end
def uglify(file)
uglified = Uglifier.compile(File.read(file))
"#{LICENSE}\n#{uglified}"
end
VERSION = File.read("VERSION").chomp
regular_path = "dist/transformjs.#{VERSION}.js"
minified_path = "dist/transformjs.#{VERSION}.min.js"
file regular_path do
puts "Generating #{regular_path}"
mkdir_p "dist"
sylvester = strip_require("lib/sylvester.js")
csshooks = strip_require("lib/css_hooks.js")
File.open(regular_path, 'w') do |file|
file.puts sylvester
file.puts csshooks
end
end
file minified_path => regular_path do
puts "Generating #{minified_path}"
File.open(minified_path, 'w') do |file|
file.puts uglify(regular_path)
end
end
desc "Clean build artifacts from previous builds"
task :clean do
sh "rm -rf tmp && rm -rf dist"
end
task :default => minified_path