-
Notifications
You must be signed in to change notification settings - Fork 6
/
make.js
62 lines (47 loc) · 1.3 KB
/
make.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
require('shelljs/make');
var requirejs = require('requirejs');
var ejs = require('ejs');
var libs = require('./client-libs');
var templateHelper = require('./util/template-html');
templateHelper.root = '../views/templates';
target.all = function() {
target.build();
};
target.build = function() {
cd(__dirname);
if (!which('uglifyjs')) {
echo("Uglifyjs is required for building.");
echo("npm install -g uglify-js");
exit(1);
}
//Clean out build target
rm('-rf', 'build/');
mkdir('build');
cd ('build');
//Images
mkdir('img');
cp('-rf', '../public/img/', './');
cp('-rf', '../bootstrap/img/', './');
//Stylesheets
mkdir('stylesheets');
exec('lessc -x ../public/stylesheets/style.less stylesheets/style.css');
//Javascripts
mkdir('js');
//Lib
var libFolder = '../public/js/lib/'
var libsjs = '';
libs.forEach(function(file) {
libsjs += exec('uglifyjs ' + libFolder + file, {silent: true}).output + '\n;\n';
});
libsjs.to('js/lib.js');
cp('../public/js/lib/require.js', 'js/require.js');
//require.js
var config = {
baseUrl: '../public/js/app',
name: 'entry',
out: '../build/js/entry.js'
};
requirejs.optimize(config);
//HTML
ejs.render(cat('../views/index.ejs'), {template: templateHelper, compile: true}).to('index.html');
};