-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
executable file
·44 lines (36 loc) · 1.06 KB
/
build.js
File metadata and controls
executable file
·44 lines (36 loc) · 1.06 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
var fs = require('fs');
var requirejs = require('requirejs');
var lib_name = 'henka';
var config = {
baseUrl: 'src',
name: lib_name,
out: 'dist/'+ lib_name + '-min.js',
gunbai: 'src/gunbai/dist/gunbai.min.js'
};
requirejs.optimize(config, function (buildResponse) {
//this appends turns the lib def into a returnable RequireJS
//module, also used by gunbai to execute standalone
var appends = [
'define(["',
lib_name,
'"], function (',
lib_name,
') { return ',
lib_name,
'; });'
];
//append gunbai to henka to add standalone capabilities
fs.appendFile(config.out, appends.join(''), function (err) {
if (err) throw err;
var out = [
config.gunbai,
config.out
].map(function(filePath){
return fs.readFileSync(filePath, 'utf-8');
});
fs.writeFileSync(config.out, out.join(''), 'utf-8');
console.log(lib_name + ' has been built!');
});
}, function(err) {
//optimization err callback
});