-
Notifications
You must be signed in to change notification settings - Fork 861
/
gulpfile.js
80 lines (67 loc) · 2.08 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
/* eslint-disable no-empty-label */
'use strict';
const gulp = require('gulp');
const concat = require('gulp-concat');
const del = require('del');
const esbuild = require('gulp-esbuild');
// eslint-disable-next-line no-var
var exports = module.exports = {};
exports.minifyJs = function(path, cb) {
const dir = path + '/js/';
function minifyPipeline(dist, src) {
return gulp.src(src.map(file => dir + file))
.pipe(esbuild({
bundle: true,
minify: true,
format: 'iife',
}))
.pipe(concat(dist + '.min.js'))
.pipe(gulp.dest(path + '/js/'));
}
function scheduleJs() {
return minifyPipeline('schedule', [
'FileSaver.js',
'social.js',
'scroll.js',
'navbar.js',
'popover.js',
'html2canvas.js',
'jquery.lazyload.js',
'icsGen.js'
])
}
function tracksJs() {
return minifyPipeline('tracks', ['social.js', 'scroll.js', 'navbar.js', 'jquery.lazyload.js']);
}
function eventJs() {
return minifyPipeline('event', ['map.js', 'scroll.js', 'navbar.js', 'popover.js', 'loklak-fetcher.js', 'tweets.js', 'jquery.lazyload.js']);
}
function roomsJs() {
return minifyPipeline('rooms', ['social.js', 'scroll.js', 'navbar.js', 'jquery.lazyload.js']);
}
function speakersJs() {
return minifyPipeline('speakers', ['social.js', 'scroll.js', 'navbar.js', 'popover.js', 'jquery.lazyload.js']);
}
function sessionJs() {
return minifyPipeline('session', ['session.js', 'social.js']);
}
function mainJs() {
return minifyPipeline('main', ['main.js']);
}
gulp.task('minifyJs', gulp.series(gulp.parallel(speakersJs, roomsJs, scheduleJs, eventJs, tracksJs, sessionJs, mainJs), async function() {
await del([dir + '*.js', '!' + dir + '*.min.js']);
cb();
}));
gulp.series('minifyJs')();
};
exports.minifyCss = function(path, cb) {
// Minify all the css files of the web-app
return gulp.src(path + '/css/*.css')
.pipe(esbuild({
loader: {'.css': 'css'},
minify: true
}))
.pipe(gulp.dest(path + '/css')).on('end', function() {
cb();
});
};