-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
90 lines (76 loc) · 2.58 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
(function() {
var gulp = require('gulp'),
del = require('del'),
browserify = require('browserify'),
strictify = require('strictify'),
buffer = require('vinyl-buffer'),
ngHtml2Js = require('gulp-ng-html2js'),
minifyHtml = require('gulp-minify-html'),
source = require('vinyl-source-stream'),
uglify = require('gulp-uglify'),
less = require('gulp-less'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
karma = require('karma').Server;
gulp.task('clean', function() {
return del('build');
});
gulp.task('build:html', function() {
return gulp.src('src/**/*.html')
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(ngHtml2Js({
moduleName: 'app',
rename: function(url) {
return url.replace('src/', '');
}
}))
.pipe(concat("custom-templates.js"))
.pipe(uglify())
.pipe(gulp.dest('build/'));
});
gulp.task('build:js', function () {
return browserify('src/index.js', { transform: strictify })
.bundle()
.pipe(source('custom-controllers.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('build/'));
});
gulp.task('build:css', function () {
return gulp.src('./src/styles/insurance-with-iin.less')
.pipe(less())
.pipe(gulp.dest('./build/'));
});
gulp.task('watch', function() {
gulp.watch('src/**/*.*', gulp.series('build:js', 'build:html'));
});
gulp.task('test:build', () => {
return gulp.src([
'node_modules/angular-mocks/angular-mocks.js',
'src/**/*.spec.js'
])
.pipe(concat('test.js'))
.pipe(gulp.dest('build/'));
});
gulp.task('test:run', (cb) => {
karma.start({
configFile: `${__dirname }/karma.conf.js`,
autoWatch: false,
singleRun: true
}, () => {
cb();
});
});
gulp.task('test', gulp.series('build:js', 'test:build', 'test:run'));
gulp.task('tdd', () => {
gulp.watch('src/**/*.*', gulp.series('test'));
});
gulp.task('build', gulp.series('build:js', 'build:html', 'build:css'));
gulp.task('default', gulp.series('clean', 'build', 'watch'));
}());