-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
59 lines (47 loc) · 1.66 KB
/
gulpfile.js
File metadata and controls
59 lines (47 loc) · 1.66 KB
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
var gulp = require('gulp'),
inject = require('gulp-inject'),
annotate = require('gulp-ng-annotate'),
babel = require("gulp-babel"),
browserify = require('browserify'),
del = require('del'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
ngAnnotate = require('gulp-ng-annotate'),
Server = require('karma').Server;
gulp.task('clean-temp', function(){
return del(['dest']);
});
gulp.task('es6-commonjs',['clean-temp'], function(){
return gulp.src(['./tst/**/*.js', './src/**/*.js'])
.pipe(babel({auxiliaryCommentBefore: 'istanbul ignore next'}))
.pipe(gulp.dest('dest/temp'));
});
gulp.task('bundle-commonjs-clean', function(){
return del(['build']);
});
gulp.task('commonjs-bundle',['bundle-commonjs-clean','es6-commonjs'], function(){
return browserify(['dest/temp/app.js']).bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(ngAnnotate())
//.pipe(uglify())
.pipe(rename('app.js'))
.pipe(gulp.dest("build"));
});
gulp.task('test', ['commonjs-bundle'], function(done){
return new Server({
configFile: __dirname + '/karma.conf.js',
singleRun : true
}, done).start();
});
gulp.task('watch', function(){
gulp.watch(['./src/**/*.js'], ['commonjs-bundle']);
gulp.watch(['./tst/**/*.js'], ['commonjs-bundle']);
});
gulp.task('watch-test',['test'], function(){
gulp.watch(['./src/**/*.js'], ['test']);
gulp.watch(['./tst/**/*.js'], ['test']);
});
gulp.task('default', ['commonjs-bundle']);