-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
63 lines (52 loc) · 1.82 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'),
bower = require('./bower.json'),
pkg = require('./package.json'),
tasks = require('gulp-load-plugins')();
// ----------------------------------------
// header
// ----------------------------------------
var header = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @author - <%= pkg.author %>',
' * @version - v<%= pkg.version %>',
' */',
''].join('\n');
// ----------------------------------------
// jshint (js lint the file)
// ----------------------------------------
gulp.task('lint', function() {
return gulp.src(['./lib/src/**/*.js'])
.pipe(tasks.jshint())
.pipe(tasks.jshint.reporter(require('jshint-stylish')));
});
// ----------------------------------------
// test
// ----------------------------------------
gulp.task('test', ['lint'], function() {
return gulp.src(['./test/*.spec.js'])
.pipe(tasks.mocha());
});
// ----------------------------------------
// js
// ----------------------------------------
gulp.task('js', ['test'], function() {
gulp.src('./lib/src/**/*.js')
.pipe(tasks.sourcemaps.init())
.pipe(tasks.concat(pkg.name + '.min.js'))
.pipe(tasks.uglify())
.pipe(tasks.header(header, {pkg: pkg}))
.pipe(tasks.sourcemaps.write('.'))
.pipe(gulp.dest('./dist/'));
});
// ----------------------------------------
// user task dist, lints, tests, and packages js and source map files into dist dir
// ----------------------------------------
gulp.task('dist', ['js']);
// ----------------------------------------
// user task default, runs watch to keep running and watching for changes
// ----------------------------------------
gulp.task('default', ['js'], function() {
tasks.watch('./lib/src/**/*.js', function(files, cb) {
gulp.start('dist', cb);
});
});