forked from Jigarsolanki/rs-popover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
110 lines (89 loc) · 2.95 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* global require */
var gulp = require('gulp');
var annotate = require('gulp-ng-annotate');
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var html2js = require('gulp-ng-html2js');
var rimraf = require('gulp-rimraf');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var webserver = require('gulp-webserver');
var merge = require('merge-stream');
var karma = require('karma');
var karmaConfig = {
browsers: ['PhantomJS'],
frameworks: ['jasmine'],
reporters: ['dots'],
preprocessors: {
'**/*.html': ['html2js']
},
ngHtml2JsPreprocessor: {
moduleName: 'rs.popover',
stripPrefix: 'src/templates/'
},
files: [
'bower_components/jquery/dist/jquery.js',
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'src/javascripts/module.js',
'src/javascripts/**/*.js',
'src/templates/**/*.html',
'test/**/*.js'
]
};
gulp.task('clean', function () {
'use strict';
return gulp.src(['coverage/**/*', 'dist/**/*'])
.pipe(rimraf());
});
gulp.task('build:concat', ['clean'], function () {
'use strict';
var javascripts = gulp.src(['src/javascripts/module.js', 'src/javascripts/**/*.js']);
var templates = gulp.src('src/templates/**/*.html')
.pipe(html2js({ moduleName: 'rs.popover' }));
return merge(javascripts, templates)
.pipe(sourcemaps.init())
.pipe(annotate())
.pipe(concat('rs-popover.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
gulp.task('build:min', ['clean'], function () {
'use strict';
var javascripts = gulp.src(['src/javascripts/module.js', 'src/javascripts/**/*.js']);
var templates = gulp.src('src/templates/**/*.html')
.pipe(html2js({ moduleName: 'rs.popover' }));
return merge(javascripts, templates)
.pipe(sourcemaps.init())
.pipe(annotate())
.pipe(concat('rs-popover.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
gulp.task('lint', function () {
'use strict';
return gulp.src(['src/javascripts/**/*.js', 'test/**/*.js', 'Gulpfile.js', 'karma.conf.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('test', function (done) {
'use strict';
karmaConfig.singleRun = true;
karmaConfig.reporters.push('coverage');
karmaConfig.coverageReporter = { type: 'lcovonly', dir: 'coverage' };
karmaConfig.preprocessors['src/javascripts/**/*.js'] = ['coverage'];
karma.server.start(karmaConfig, done);
});
gulp.task('test:watch', function (done) {
'use strict';
karma.server.start(karmaConfig, done);
});
gulp.task('server', ['build:concat', 'build:min'], function () {
'use strict';
gulp.watch(['src/**/*'], ['build:concat', 'build:min']);
return gulp.src(['bower_components', 'docs', 'dist'])
.pipe(webserver({ livereload: true }));
});
gulp.task('default', ['lint', 'test', 'build:concat', 'build:min']);