forked from alphatr/jquery-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (65 loc) · 1.89 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
var gulp = require('gulp-param')(require('gulp'), process.argv);
var uglify = require('gulp-uglifyjs');
var jsList = [
"src/qrbase.js",
"src/reedsolomon.js"
];
var outFile = 'jquery';
var gDebug = false;
gulp.task('dep', function(debug, file, render) {
gDebug = !!debug;
if (file === 'decode') {
outFile += '-qrdecode';
jsList.push("src/decode.js");
jsList.push("src/qrdecode.js");
} else if (file === 'encode') {
outFile += '-qrencode';
jsList.push("src/encode.js");
jsList.push("src/qrcode.js");
if (render === 'table') {
outFile += '-table';
jsList.push("src/render.table.js");
} else if (render === 'canvas') {
outFile += '-canvas';
jsList.push("src/render.canvas.js");
} else {
jsList.push("src/render.table.js");
jsList.push("src/render.canvas.js");
}
} else {
outFile += '-qrcode';
jsList.push("src/decode.js");
jsList.push("src/qrdecode.js");
jsList.push("src/encode.js");
jsList.push("src/qrcode.js");
if (render === 'table') {
outFile += '-table';
jsList.push("src/render.table.js");
} else if (render === 'canvas') {
outFile += '-canvas';
jsList.push("src/render.canvas.js");
} else {
jsList.push("src/render.table.js");
jsList.push("src/render.canvas.js");
}
}
if (!gDebug) {
outFile += '.min';
}
outFile += '.js';
});
gulp.task('build', ['dep'], function() {
var opts = {};
if (gDebug) {
opts = {
mangle: false,
output: {
beautify: true
}
};
}
return gulp.src(jsList, {base: 'src'})
.pipe(uglify(outFile, opts))
.pipe(gulp.dest('dest/'));
});
gulp.task('default', ['build']);