-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathesbuild.js
More file actions
executable file
·100 lines (89 loc) · 2.69 KB
/
esbuild.js
File metadata and controls
executable file
·100 lines (89 loc) · 2.69 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
94
95
96
97
98
99
100
#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const esbuild = require('esbuild');
const pkg = require('./package.json');
const outdir = path.join(__dirname, 'deploy/');
const static_files = {'./src/index.html' : '',
'./src/favicon.ico' : '',
'./src/app/data/benchmark.json' : 'data',
'./src/app/data/foaf.json' : 'data',
'./src/app/data/goodrelations.json' : 'data',
'./src/app/data/muto.json' : 'data',
'./src/app/data/new_ontology.json' : 'data',
'./src/app/data/ontovibe.json' : 'data',
'./src/app/data/personasonto.json' : 'data',
'./src/app/data/sioc.json' : 'data',
'./src/app/data/template.json' : 'data',
'./parser_test/web_parser.js' : 'js',
'./parser_test/parser.js' : 'js',
'./parser_test/sorter.js' : 'js',
'./node_modules/d3/d3.min.js' : 'js',
'./node_modules/rdflib/dist/rdflib.min.js' : 'js'
};
const options = {
bundle: true,
outdir: outdir,
external: ['d3', './web_parser.js'],
minify: false,
sourcemap: true,
// target: 'es2015',
format:'iife',
platform: 'browser',
entryNames: '[ext]/[name]',
plugins: [{
name: 'watch',
setup({ onEnd }) {
onEnd((ret) => {
})
}
}]
};
function copy_static_file(file) {
const p = path.join(__dirname, file);
var data = fs.readFileSync(p)
if(file.endsWith('index.html'))
data = data.toString('utf8').replaceAll('<%= version %>', pkg.version);
const foutDir = path.join(outdir, static_files[file]);
try { fs.mkdirSync(foutDir, 0775); } catch(e) {}
fs.writeFileSync(path.join(foutDir, path.basename(p)), data);
}
function copy_static() {
for(var file in static_files) copy_static_file(file);
}
function watch_static() {
try { fs.mkdirSync(outdir, 0775); } catch(e) {}
for(var file in static_files) {
(function (f) {
fs.watchFile(path.join(__dirname, f), {
bigint: false,
persistent: true,
interval: 1000,
}, () => {
copy_static_file(f);
});
})(file);
}
console.log('watching...');
}
function build(opt) {
esbuild.context(Object.assign(opt, options))
.then((r) => {
r.watch();
console.log('watching...');
}).catch(() => process.exit(1));
}
copy_static();
watch_static();
build({
entryPoints: {
'js/webvowl': './src/webvowl/js/entry.js'
},
globalName: 'webvowl'
});
build({
entryPoints: {
'js/webvowl.app': './src/app/js/entry.js'
},
globalName: 'webvowl.app'
});