forked from QuickBlox/quickblox-javascript-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
111 lines (93 loc) · 2.74 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
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var connect = require('gulp-connect');
var notify = require('gulp-notify');
var uglify = require('gulp-uglify');
var pump = require('pump');
var fs = require('fs');
var builder = require('jquery-custom');
gulp.task('build', function () {
var isDevelopment = process.env.NODE_ENV === 'develop',
browserifyOpts = {
debug: isDevelopment,
standalone: 'QB'
};
return browserify('./src/qbMain.js', browserifyOpts)
.bundle()
.on('error', function(error) {
notify('Failed when create a bundle.');
this.emit('end');
})
.pipe(source('quickblox.min.js'))
.pipe(gulp.dest('./'))
.pipe(notify('Build task is finished.'));
});
gulp.task('minify', function () {
pump([
gulp.src('./quickblox.min.js'),
uglify(),
notify('Minify task is finished.'),
gulp.dest('./')
]);
});
gulp.task('connect', function() {
connect.server({
port: 8080,
https: true
});
});
gulp.task('generate-build_version', function() {
var fs = require('fs');
const configPath = './src/qbConfig.js';
function incBuildNumber(foundedString, p1, buildNumber, p2) {
var oldBuildNumber = +buildNumber;
return p1 + (oldBuildNumber + 1) + p2;
}
fs.readFile(configPath, 'utf8', function (error, config) {
if (error) {
throw new Error(error);
}
var result = config.replace(/(buildNumber:\s\')(\d{4})(')/g, incBuildNumber);
fs.writeFile(configPath, result, 'utf8', function (error) {
if (error) {
throw new Error(error);
}
});
});
});
gulp.task('jquery', function () {
return builder({
flags: [
'-deprecated',
'-dimensions',
'-effects',
'-event',
'-event/alias',
'-event/focusin',
'-event/trigger',
'-offset',
'-wrap',
'-core/ready',
'-exports/global',
'-sizzle'
],
}, function (err, compiledContent) {
if (err){
notify('Can\'t build jquery lib.');
return console.error(err);
}
fs.writeFile('./src/plugins/jquery.ajax.js', compiledContent, function (err) {
if (err){
notify('Can\'t build jquery lib.');
return console.error(err);
}
notify('Jquery task is finished.');
})
})
});
gulp.task('watch', function () {
gulp.watch(['./src/**/*.js'], ['build']);
});
gulp.task('default', ['build', 'connect', 'watch']);