-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
55 lines (47 loc) · 1.89 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
55
var gulp = require('gulp');
var webpack = require('webpack-stream');
var merge = require('merge2');
const replace = require('gulp-replace');
var clean = require('gulp-clean');
var args = require('yargs').argv;
var apps = ['zimbra'];
var apps_viewonly = ['apizimbra'];
if (args.module) {
apps = [args.module];
}
gulp.task('drop-cache', function () {
var streams = [];
apps.forEach(function (app) {
streams.push(gulp.src(['./' + app + '/src/main/resources/public/dist'], {read: false}).pipe(clean()))
streams.push(gulp.src(['./' + app + '/build'], {read: false}).pipe(clean()))
});
return merge(streams);
});
gulp.task('webpack', ['drop-cache'], function () {
var streams = [];
apps.forEach(function (app) {
streams.push(gulp.src('./' + app + '/src/main/resources/public')
.pipe(webpack(require('./' + app + '/webpack.config.js')))
.on('error', function handleError() {
this.emit('end'); // Recover from errors
})
.pipe(gulp.dest('./' + app + '/src/main/resources/public/dist')))
});
return merge(streams);
});
gulp.task('build', ['webpack'], function () {
var streams = [];
apps.forEach(function (app) {
streams.push(gulp.src("./" + app + "/src/main/resources/view-src/**/*.+(html|txt|json)")
.pipe(replace('@@VERSION', Date.now()))
.pipe(gulp.dest("./" + app + "/src/main/resources/view")));
streams.push(gulp.src("./" + app + "/src/main/resources/public/dist/behaviours.js")
.pipe(gulp.dest("./" + app + "/src/main/resources/public/js")));
});
apps_viewonly.forEach(function (app) {
streams.push(gulp.src("./" + app + "/src/main/resources/view-src/**/*.+(html|txt|json)")
.pipe(replace('@@VERSION', Date.now()))
.pipe(gulp.dest("./" + app + "/src/main/resources/view")));
});
return merge(streams);
});