-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathgulpfile.js
71 lines (58 loc) · 2.07 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
68
69
70
71
'use strict';
var gulp = require('gulp');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require('gulp-uglify');
var wrap = require('gulp-wrap');
var bump = require('gulp-bump');
var gulpKarma = require('gulp-karma');
var rename = require('gulp-rename');
var gulpSequence = require('gulp-sequence').use(gulp);
var pkg = require('./package.json');
var files = require('./files');
var karmaTestConfig = gulpKarma({configFile: 'karma.conf.js', action: 'run'});
var banner = '/*!\n' +
' * <%= pkg.name %>\n' +
' * <%= pkg.description %>\n' +
' * @version v<%= pkg.version %>\n' +
' * @link <%= pkg.homepage %>\n' +
' * @license <%= pkg.license %> License, http://www.opensource.org/licenses/<%= pkg.license %>\n' +
' */\n';
gulp.task('bump', function(){
return gulp.src('./*.json')
.pipe(bump({type:'minor'}))
.pipe(gulp.dest('./'));
});
gulp.task('buildDev', function () {
return gulp.src(files.mergeFilesFor('src'))
.pipe(wrap(banner+'(function(window, angular, undefined){<%= contents %>})(window, window.angular);', {pkg: pkg}))
.pipe(ngAnnotate())
.pipe(gulp.dest('./build/'));
});
gulp.task('minBuild', function () {
return gulp.src('./build/'+pkg.name+'.js')
.pipe(uglify({
outSourceMap: false,
mangle: true,
preserveComments: 'license'
}))
.pipe(rename(pkg.name+'.min.js'))
.pipe(gulp.dest('./build/'));
});
gulp.task('copyBuild', function () {
return gulp.src('./build/*.js')
.pipe(gulp.dest('./dist/'));
});
gulp.task('default', function(){
return gulp.watch(files.mergeFilesFor('src'), ['test']);
});
gulp.task('test', function () {
return gulp.src(files.mergeFilesFor('karma-src')).pipe(karmaTestConfig);
});
gulp.task('testBuild', function () {
return gulp.src(files.mergeFilesFor('karma-build')).pipe(karmaTestConfig);
});
gulp.task('testMin', function () {
return gulp.src(files.mergeFilesFor('karma-min')).pipe(karmaTestConfig);
});
gulp.task('build', gulpSequence('buildDev', 'minBuild', ['testBuild','testMin']));
gulp.task('release', gulpSequence('bump', 'build', 'copyBuild'));