forked from erikringsmuth/app-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (50 loc) · 1.33 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
'use strict';
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var inline = require('gulp-inline');
var karma = require('gulp-karma');
var files = ['src/*.js', 'tests/spec/*.js'];
gulp.task('lint', function() {
return gulp.src(files)
.pipe(jshint.extract('always'))
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('build', function() {
return gulp.src('src/app-router.js')
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(gulp.dest('.'));
});
gulp.task('minify', function() {
return gulp.src('src/app-router.html')
.pipe(inline({
base: 'src',
js: uglify()
}))
.pipe(gulp.dest('.'));
});
gulp.task('test', function() {
return gulp.src(files)
.pipe(karma({
configFile: 'tests/karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
// make sure failed tests cause gulp to exit non-zero
console.log(err);
});
});
// watch
gulp.task('watch', function() {
gulp.watch(files, ['lint', 'build', 'minify', 'test'])
.on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});
});
// default
gulp.task('default', ['lint', 'build', 'minify', 'test']);
// Travis CI
gulp.task('ci', ['lint']);