-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
54 lines (41 loc) · 1.44 KB
/
gulpfile.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
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
var del = require('del');
var source = require('vinyl-source-stream');
var babel = require('babelify');
var parseArgs = require('minimist');
var args = parseArgs(process.argv.slice(2));
const defaultTarget = 'target';
var projects = ['metaentry', 'labeling', 'sparqlclient'];
projects.forEach(function(project){
var paths = {
main: 'src/main/js/' + project + '/main.js',
jsx: ['src/main/js/' + project + '/**/*.jsx'],
js: ['src/main/js/' + project + '/**/*.js'],
common: ['src/main/js/common/**/*.js'],
target: (args.target || defaultTarget) + '/www/',
bundleFile: project + '.js'
};
gulp.task('clean' + project, async function() {
del([paths.target + paths.bundleFile]);
});
gulp.task('build' + project, function() {
console.log("Building " + project + " to " + paths.target);
return browserify({
entries: [paths.main],
debug: false,
transform: [babel]
})
.bundle()
.pipe(source(paths.bundleFile))
.pipe(gulp.dest(paths.target));
});
gulp.task('js' + project, gulp.series('clean' + project, 'build' + project));
gulp.task('watch' + project, function() {
var sources = paths.js.concat(paths.jsx, paths.common);
gulp.watch(sources, gulp.series(['js' + project]));
});
gulp.task(project, gulp.series(['watch' + project, 'js' + project]));
});
gulp.task('default', gulp.series(projects.map(function(p){return 'js' + p;})));