-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
69 lines (60 loc) · 2.28 KB
/
build.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
63
64
65
66
67
68
69
#!/usr/bin/env node
'use strict';
const Vulcanize = require('vulcanize');
const async = require('async');
const path = require('path');
const shell = require('shelljs');
const fs = require('fs');
var name = "hipathia";
var element = "hipathia-element";
// Default
var bp = path.join(__dirname, "build");
var indexHTML = path.join(__dirname, name + '-index.html');
var buildIndexHTML = path.join(bp, 'index.html');
var elementHTML = path.join(__dirname, element + '.html');
var buildElementHTML = path.join(bp, element + '.html');
var vulcan = new Vulcanize({
inlineScripts: true,
inlineCss: true,
stripComments: true
});
async.waterfall([
function (cb) {
shell.rm('-rf', bp);
shell.mkdir('-p', bp);
shell.mkdir('-p', path.join(bp, "fontawesome"));
shell.mkdir('-p', path.join(bp, "webcomponentsjs"));
cb(null);
},
function (cb) {
vulcan.process(elementHTML, function (err, inlinedHtml) {
fs.writeFile(buildElementHTML, inlinedHtml, function (err) {
if (err) {
cb(err);
} else {
cb(null);
}
});
});
},
function (cb) {
shell.cp('-r', indexHTML, buildIndexHTML);
shell.cp('-r', path.join(__dirname, 'conf/'), bp);
shell.cp('-r', path.join(__dirname, 'images/'), bp);
shell.cp('-r', path.join(__dirname, 'pathway_list.json'), bp);
shell.cp('-r', path.join(__dirname, 'bower_components', 'stevia-elements', 'fonts'), bp);
shell.cp('-r', path.join(__dirname, 'bower_components', 'stevia-elements', 'css'), bp);
shell.cp('-r', path.join(__dirname, 'bower_components', 'fontawesome', 'css'), path.join(bp, "fontawesome/"));
shell.cp('-r', path.join(__dirname, 'bower_components', 'fontawesome', 'fonts'), path.join(bp, "fontawesome/"));
shell.cp('-r', path.join(__dirname, 'bower_components', 'webcomponentsjs', '*.min.js'), path.join(bp, "webcomponentsjs/"));
// fix index.html paths
shell.sed('-i', 'bower_components/stevia-elements/', '', buildIndexHTML);
shell.sed('-i', 'bower_components/', '', buildIndexHTML);
cb(null);
}
], function (err) {
if (err) {
console.log(err);
}
console.log("Done.");
});