forked from fossasia/open-event-wsgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
118 lines (100 loc) · 3.88 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var babel = require('gulp-babel');
var concat = require('gulp-concat');
var minify = require('gulp-minify-css');
var htmlmin = require('gulp-htmlmin');
var iife = require('gulp-iife');
var clean = require('gulp-clean');
var exports = module.exports = {};
exports.minifyJs = function (path, cb) {
var dir = path + "/js/";
gulp.task('scheduleJs', function() {
return gulp.src([dir + 'FileSaver.js', dir + 'social.js', dir + 'scroll.js', dir + 'navbar.js', dir + 'calendar.js', dir + 'popover.js', dir + 'html2canvas.js', dir + 'jquery.lazyload.js', dir + 'icsGen.js'])
.pipe(iife({ useStrict : false}))
.pipe(concat('schedule.min.js'))
.pipe(babel({ presets: ['es2015'] }))
.pipe(uglify().on('error', function(e) {
console.log("Error while compiling schedule.js");
}))
.pipe(gulp.dest(path + '/js/'));
});
gulp.task('tracksJs', function() {
return gulp.src([dir + 'social.js', dir + 'scroll.js', dir + 'navbar.js', dir + 'jquery.lazyload.js'])
.pipe(iife({ useStrict : false}))
.pipe(concat('tracks.min.js'))
.pipe(babel({ presets: ['es2015'] }))
.pipe(uglify().on('error', function(e) {
console.log("Error while compiling tracks.js");
}))
.pipe(gulp.dest(path + '/js/'));
});
gulp.task('eventJs', function() {
return gulp.src([dir + 'map.js', dir + 'scroll.js', dir + 'navbar.js', dir + 'popover.js', dir + 'loklak-fetcher.js', dir + 'tweets.js', dir + 'jquery.lazyload.js'])
.pipe(iife({ useStrict : false}))
.pipe(concat('event.min.js'))
.pipe(babel({ presets: ['es2015'] }))
.pipe(uglify().on('error', function(e) {
console.log("Error while compiling event.js");
}))
.pipe(gulp.dest(path + '/js/'));
});
gulp.task('roomsJs', function() {
return gulp.src([dir + 'social.js', dir + 'scroll.js', dir + 'navbar.js', dir + 'jquery.lazyload.js'])
.pipe(iife({ useStrict : false}))
.pipe(concat('rooms.min.js'))
.pipe(babel({ presets: ['es2015'] }))
.pipe(uglify().on('error', function(e) {
console.log("Error while compiling rooms.js");
}))
.pipe(gulp.dest(path + '/js/'));
});
gulp.task('speakersJs', function() {
return gulp.src([dir + 'social.js', dir + 'scroll.js', dir + 'navbar.js', dir + 'popover.js', dir + 'jquery.lazyload.js'])
.pipe(iife({ useStrict : false}))
.pipe(concat('speakers.min.js'))
.pipe(babel({ presets: ['es2015'] }))
.pipe(uglify().on('error', function(e) {
console.log("Error while compiling speakers.js");
}))
.pipe(gulp.dest(path + '/js/'));
});
gulp.task('sessionJs', function() {
return gulp.src([dir + 'session.js', dir + 'social.js'])
.pipe(iife({ useStrict : false}))
.pipe(concat('session.min.js'))
.pipe(babel({ presets: ['es2015'] }))
.pipe(uglify().on('error', function(e) {
console.log('Error while compiling session.js');
}))
.pipe(gulp.dest(path + '/js/'));
});
gulp.task('minifyJs', ['speakersJs', 'roomsJs', 'scheduleJs', 'eventJs', 'tracksJs', 'sessionJs'], function() {
gulp.src(['!' + dir + '*.min.js', dir + "*.js"])
.pipe(clean());
cb();
});
gulp.start('minifyJs');
};
exports.minifyCss = function (path, cb) {
gulp.task('minifyCss', function() {
//Minify all the css files of the web-app
return gulp.src(path + '/css/*.css')
.pipe(minify())
.pipe(gulp.dest(path + '/css')).on('end', function() {
cb();
});
});
gulp.start('minifyCss');
};
exports.minifyHtml = function (path,cb) {
gulp.task('minifyHtml', function() {
//Minify all the html files of the web-app
return gulp.src(path + '/*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest(path)).on('end', function() {
cb();
});
});
gulp.start('minifyHtml');
};