-
Notifications
You must be signed in to change notification settings - Fork 36
/
gulpfile.js
63 lines (53 loc) · 1.36 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
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
mocha = require('gulp-mocha')
define = require('gulp-define-module')
lazypipe = require('lazypipe');
var SRC_FILE = './src/minivents.js'
, OUTPUT_DIR = './dist';
var modulify = function(type) {
return lazypipe()
.pipe(define, type)
.pipe(rename, function(p) {
if (type == 'plain')
return;
p.basename += '.' + type;
})
.pipe(gulp.dest, OUTPUT_DIR)();
};
gulp.task('hint', function () {
return gulp.src(SRC_FILE)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('test', ['build'], function () {
return gulp.src('./test.js')
.pipe(mocha());
});
gulp.task('build.amd', function() {
return gulp.src(SRC_FILE).pipe(modulify('amd'));
});
gulp.task('build.commonjs', function() {
return gulp.src(SRC_FILE).pipe(modulify('commonjs'));
});
gulp.task('build.plain', function() {
return gulp.src(SRC_FILE).pipe(modulify('plain'));
});
gulp.task('build', [
'build.amd',
'build.commonjs',
'build.plain'
], function () {
return gulp.src([
OUTPUT_DIR + '/**/*',
'!**/*.min.js'
])
.pipe(uglify())
.pipe(rename(function(p) {
p.basename += '.min';
}))
.pipe(gulp.dest(OUTPUT_DIR));
});
gulp.task('default', ['test']);