forked from fossasia/open-event-wsgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
90 lines (76 loc) · 2.51 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
/* eslint-disable no-empty-label */
'use strict';
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const minify = require('gulp-minify-css');
const htmlmin = require('gulp-htmlmin');
const iife = require('gulp-iife');
const del = require('del');
// 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(iife({useStrict: false}))
.pipe(concat(dist + '.min.js'))
.pipe(babel({presets: ['es2015']}))
.pipe(uglify().on('error', function(e) {
console.log(`Error while compiling ${dist}.js` + e);
}))
.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(minify())
.pipe(gulp.dest(path + '/css')).on('end', function() {
cb();
});
};
exports.minifyHtml = function(path, cb) {
// 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();
});
};