forked from fossasia/open-event-wsgen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
132 lines (113 loc) · 4.2 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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 swPrecache = require('sw-precache');
var exports = module.exports = {};
exports.minifyJs = function (path, cb) {
var dir = path + "/js/";
gulp.task('scheduleJs', function() {
return gulp.src([dir + 'social.js', dir + 'scroll.js', dir + 'navbar.js', dir + 'calendar.js', dir + 'popover.js', dir + 'jquery.lazyload.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 + 'tabs.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 + 'tabs.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('minifyJs',['speakersJs', 'roomsJs', 'scheduleJs', 'eventJs', 'tracksJs'], 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,wrk,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.task('generate-service-worker', function() {
swPrecache.write(path + '/service-worker.js', {
staticFileGlobs: [wrk + '/**/*.{html,css,png,jpg,gif,svg,eot,ttf,woff}', wrk + '/*.html', wrk + '/**/*.min.js'],
/* stripPrefixMulti: {
path
}*/
});
return gulp.src(path + '/service-worker.js')
.pipe(iife({ useStrict : false}))
.pipe(concat('service-worker.min.js'))
.pipe(babel({ presets: ['es2015'] }))
.pipe(uglify().on('error', function(e) {
console.log("Error while compiling service-worker.js");
}))
.pipe(gulp.dest(path + '/'));
});
var dir = path + '.';
gulp.task('minifyHtml',['generate-service-worker'], function() {
gulp.src(['!' + dir + '*.min.js', dir + "*.js"])
.pipe(clean())
cb();
});
gulp.start('minifyHtml');
};