-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.js
More file actions
37 lines (31 loc) · 788 Bytes
/
build.js
File metadata and controls
37 lines (31 loc) · 788 Bytes
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
var http = require('http'),
fs = require('fs'),
stringify = require('querystring').stringify;
var SRC_FILES = [
'core.js',
'event.js',
'ajax.js',
'data.js'
];
var src = SRC_FILES.reduce(function(buffer, file) {
return buffer + fs.readFileSync('./src/' + file) + '\n';
}, '');
var req = http.request({
host: 'closure-compiler.appspot.com',
port: 80,
path: '/compile',
method: 'POST',
headers: { 'Content-type': 'application/x-www-form-urlencoded' }
}, function(res) {
res.on('data', function(chunk) {
fs.writeFile('./dist/yocto.min.js', chunk);
});
});
fs.writeFile('./dist/yocto.js', src);
req.write(stringify({
js_code: src,
compilation_level: 'ADVANCED_OPTIMIZATIONS',
output_format: 'text',
output_info: 'compiled_code'
}));
req.end();