forked from plugCubed/plugCubed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_compile.js
65 lines (61 loc) · 2.07 KB
/
_compile.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
59
60
61
62
63
64
65
var ClosureCompiler, compressor, fs;
ClosureCompiler = require("closurecompiler");
compressor = require('yuicompressor');
fs = require('fs');
function compileJS(input, output) {
ClosureCompiler.compile([input], {
compilation_level: 'SIMPLE_OPTIMIZATIONS',
process_jquery_primitives: true,
charset: 'utf-8',
language_in: 'ECMASCRIPT5'
}, function(error, result) {
if (error)
console.log(error);
if (result) {
fs.writeFile(output, result, function(err) {
if (err) {
console.log('[JS] Could not save to file', err);
} else {
console.log('[JS] Saved to file');
}
});
}
});
}
function compileCSS(input, output) {
compressor.compress(input, {
charset: 'utf8',
type: 'css',
'line-break': 1
}, function(err, data) {
if (err) {
console.log('[CSS] Could not save to file', err);
return;
}
fs.writeFile(output, data, function(err) {
if (err) {
console.log('[CSS] Could not save to file', err);
} else {
console.log('[CSS] Saved to file');
}
});
});
}
if (process.argv[2].indexOf('--dir ') === 0) {
switch (process.argv[2].substr(6)) {
case 'release':
compileJS('./bin/release/plugCubed.js', './bin/release/plugCubed.min.js');
compileCSS('./src/release/plugCubed.css', './bin/release/plugCubed.css');
break;
case 'alpha':
compileJS('./bin/alpha/plugCubed.js', './bin/alpha/plugCubed.min.js');
compileCSS('./src/alpha/plugCubed.css', './bin/alpha/plugCubed.css');
break;
case 'dev':
compileJS('./bin/dev/plugCubed.js', './bin/dev/plugCubed.min.js');
compileCSS('./src/dev/plugCubed.css', './bin/dev/plugCubed.css');
break;
default:
console.log('[COMPILE] Unknown dir');
}
} else console.log('[COMPILE] Unknown dir');