-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgulpfile.js
57 lines (47 loc) · 1.42 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
var gulp = require('gulp'),
pkg = require('./package.json'),
$ = require('gulp-load-plugins')();
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
gulp.task('jshint', function () {
var stream = gulp.src('./src/*.js')
.pipe($.jshint({ lookup: true }))
.pipe($.jshint.reporter($.stylish))
.pipe($.jshint.reporter('fail'));
return stream;
});
gulp.task('test', function () {
var stream = gulp.src('test/runner.html')
.pipe($.mochaPhantomjs());
return stream;
});
gulp.task('build', ['jshint'], function () {
//
// Uglify and add banner to javascript files
//
gulp.src('./src/*.js')
.pipe($.header(banner, { pkg: pkg } ))
.pipe(gulp.dest('./dist/'))
.pipe($.uglify())
.pipe($.header(banner, { pkg: pkg } ))
.pipe($.rename({ suffix: '.min' }))
.pipe(gulp.dest('./dist/'));
//
// Autoprefix and add banner to css files
//
gulp.src('./src/*.css')
.pipe($.autoprefixer('last 1 version', '> 1%', 'ie 8', 'ie 7'))
.pipe($.csscomb('zen'))
.pipe($.header(banner, { pkg: pkg } ))
.pipe(gulp.dest('./dist/'));
});
gulp.task('default', ['jshint', 'test', 'build']);
gulp.task('travis', ['jshint', 'test']);
gulp.task('watch', function() {
gulp.watch(['src/*.js', 'test/test.js'], ['jshint', 'test']);
});