-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
75 lines (56 loc) · 1.44 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
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
pump = require('pump'),
del = require('del'),
buffer = require('gulp-buffer'),
source = require('vinyl-source-stream'),
rename = require('gulp-rename'),
tap = require('gulp-tap'),
browserify = require('browserify');
var tasks = ['rearmed','array','object','number','string','generic'];
tasks.forEach(function(item, i){
gulp.task(item, [], function(cb){
var filename = '';
if(item !== 'rearmed'){
filename += 'rearmed/';
}
filename += item + '.js';
del(filename);
del(filename.replace('.js','.min.js'));
pump([
browserify(('./src/'+filename), {
debug: false,
}).bundle(),
source(filename.replace('rearmed/','')),
buffer(),
gulp.dest('./'),
uglify(),
rename({
suffix: '.min'
}),
gulp.dest('./dist/')
], cb);
});
});
gulp.task('other', [], function(cb){
pump([
gulp.src('./src/rearmed/*/**/*.js'),
tap(function(file){
file.contents = browserify(file.path, {
debug: false,
}).bundle();
}),
buffer(),
gulp.dest('./'),
uglify(),
rename(function(path){
path.dirname = path.dirname.replace('rearmed/','')
path.extname = '.min.js'
}),
gulp.dest('./dist/')
], cb);
});
gulp.task('default', tasks.concat(['other']));
gulp.task('watch', function() {
gulp.watch(paths.src, ['default']);
});