-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jakefile
32 lines (29 loc) · 1.01 KB
/
Jakefile
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
var fs = require('fs'),
sys = require('sys');
desc('This is the default build task.');
task('default', function (params) {
var files = new jake.FileList('src/*.js'),
content = '',
mainFile = 'src/easy.js',
mainIndex = files.indexOf(mainFile);
files.splice(mainIndex, 1);
files.unshift(mainFile);
content = files.map(function(file, i) {
return fs.readFileSync(file).toString();
}).join('\n');
var out = fs.openSync('easy.js', 'w+');
fs.writeSync(out, content);
fs.closeSync(out);
console.log('build successful');
});
task('minify', ['default'], function(params) {
var uglify = require('uglify-js');
var originFile = fs.readFileSync('easy.js').toString(),
ast = uglify.parser.parse(originFile),
out = fs.openSync('easy.min.js', 'w+');
ast = uglify.uglify.ast_mangle(ast);
ast = uglify.uglify.ast_squeeze(ast);
fs.writeSync(out, uglify.uglify.gen_code(ast));
fs.closeSync(out);
console.log('minify successful ');
});