-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
67 lines (56 loc) · 1.48 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
var gulp = require('gulp');
var karma = require('karma').server;
var runSequence = require('run-sequence');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate')
var rename = require('gulp-rename');
var del = require('del');
var vinylPaths = require('vinyl-paths');
var path = {
src: './src/*.js',
tests: './tests/*.js',
output: 'dist'
};
gulp.task('test:unit', function(done) {
karma.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done);
});
gulp.task('test', ['test:unit']);
gulp.task('jshint', function() {
gulp.src([path.src, path.tests])
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('clean', function() {
return gulp.src([path.output])
.pipe(vinylPaths(del));
});
gulp.task('build:src:min', function() {
gulp.src(path.src)
.pipe(ngAnnotate({
remove: true,
add: true,
single_quotes: true
}))
.pipe(uglify())
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest(path.output));
});
gulp.task('build:src', ['build:src:min'], function() {
gulp.src(path.src)
.pipe(gulp.dest(path.output));
});
gulp.task('build', ['jshint'], function(done) {
return runSequence(
'clean',
'test',
'build:src',
done);
});