-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuildscript.js
More file actions
94 lines (74 loc) · 2.68 KB
/
buildscript.js
File metadata and controls
94 lines (74 loc) · 2.68 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Run:
* node buildscript.js
* in the nexus directory to create a basic build of nexusUI.js
* with supplrementary element files combined into one file.
* I've included a minify function but it is not working at the moment
* so I commented out the function call.
*
* Code written with assist from http://blog.millermedeiros.com/node-js-as-a-build-script/
*
*/
var FILE_ENCODING = 'utf-8',
EOL = '\n';
var _fs = require('fs');
function concat(opts) {
var fileList = opts.src;
var distPath = opts.dest;
var out = fileList.map(function(filePath){
return _fs.readFileSync(filePath, FILE_ENCODING);
});
_fs.writeFileSync(distPath, out.join(EOL), FILE_ENCODING);
console.log(' '+ distPath +' built!');
}
function uglify(srcPath, distPath) {
var UglifyJS = require("uglify-js");
var result = UglifyJS.minify(srcPath);
_fs.writeFileSync(distPath, result.code, FILE_ENCODING);
//console.log(result.code); // minified output
// if you need to pass code instead of file name
//var result = UglifyJS.minify("var b = function () {};", {fromString: true});
/* var jsp = require('uglify-js').parser;
var pro = require('uglify-js').uglify;
console.log(jsp);
var ast = jsp.parse( _fs.readFileSync(srcPath, FILE_ENCODING) );
ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);
_fs.writeFileSync(distPath, pro.gen_code(ast), FILE_ENCODING); */
console.log(' '+ distPath +' is built!');
}
concat({
src : [
'nexusUI/nexusUI.js',
'nexusUI/nexusToggle.js',
'nexusUI/nexusDial.js',
'nexusUI/nexusButton.js',
'nexusUI/nexusKeyboard.js',
'nexusUI/nexusPosition.js',
'nexusUI/nexusMatrix.js',
'nexusUI/nexusSlider.js',
'nexusUI/nexusMultislider.js',
'nexusUI/nexusSelect.js',
'nexusUI/nexusTilt.js',
'nexusUI/nexusSandbox.js',
'nexusUI/nexusJoints.js',
'nexusUI/nexusColors.js',
'nexusUI/nexusPixels.js',
'nexusUI/nexusNumber.js',
'nexusUI/nexusComment.js',
'nexusUI/nexusMessage.js',
'nexusUI/nexusPanel.js',
'nexusUI/nexusBanner.js',
'nexusUI/nexusMultitouch.js',
'nexusUI/nexusMetroball.js',
'nexusUI/nexusString.js'
],
dest : 'CurrentBuild/nexusUI.js'
});
/* this minify script is throwing an error in the jsp.parse() line ... not sure why */
uglify('CurrentBuild/nexusUI.js', 'CurrentBuild/nexusUI.min.js');
/* Also - could auto-read files from dir as below, but how to choose only JS files and only those we want?
better to just list it above, for now. ?
var nexusfiles = _fs.readdirSync("nexusUI");
console.log(nexusfiles);
*/