-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
58 lines (44 loc) · 1.33 KB
/
build.js
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
var compressor = require("node-minify");
var fs = require("fs");
function print(msg) {process.stdout.write(msg)}
function done() {print("[done] \n")}
function concat() {
print("joining files...");
return compressor.minify({
compressor: "no-compress",
input: ["src/umd/_head", "src/class-lists.js", "src/hut.js", "src/hut-view.js", "src/umd/_tail"],
output: "bin/react-hut.js"
}).then(done);
}
function compile() {
print("compiling...");
return compressor.minify({
compressor: "gcc",
input: "bin/react-hut.js",
output: "bin/react-hut.js",
options: {
compilation_level: "ADVANCED_OPTIMIZATIONS",
language: "ECMASCRIPT5_STRICT"
}
}).then(done);
}
function copy(from, to) {
print("copying...");
fs.writeFileSync(to, fs.readFileSync(from));
done();
}
var targets = {
help: function() {
console.log("here be help");
},
dev : function() {concat()},
prod : function () {concat().then(compile)},
dist : function () {
concat()
.then(() => copy("./bin/react-hut.js", "./dist/react-hut.js"))
.then(compile)
.then(() => copy("./bin/react-hut.js", "./dist/react-hut.min.js"))
}
};
// run selected target
(targets[process.argv[2]] || targets["help"]).call();