-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
95 lines (76 loc) · 2.06 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var clean = require('gulp-clean');
var minifyCss = require('gulp-minify-css');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var gulpIgnore = require('gulp-ignore');
var ngAnnotate = require('gulp-ng-annotate');
var sass = require('gulp-sass');
var karma = require('gulp-karma');
var watch = require('gulp-watch');
var paths = [
'./src/js/*.*',
'./src/css/*.*'
];
gulp.task('sass', function () {
'use strict';
return gulp.src('./src/scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('./src/css'));
});
gulp.task('lint', function () {
'use strict';
return gulp.src('./src/js/*.js')
.pipe(jshint({lookup: true}))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('minify-css', ['sass'], function () {
'use strict';
return gulp.src('./src/css/*.css', {base: './src'})
.pipe(minifyCss({keepBreaks: true}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('uglifyJS', ['lint'], function () {
'use strict';
return gulp.src(['./src/js/*.js'], {base: './src'})
.pipe(gulpIgnore.exclude(['./src/js/*-spec.js']))
.pipe(ngAnnotate())
.pipe(uglify({
outSourceMap: true
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('copy', ['minify-css'], function () {
'use strict';
return gulp.src('./src/templates/*', {base: './src'})
.pipe(gulp.dest('./dist'));
});
gulp.task('clean', function () {
'use strict';
return gulp.src('./dist/**/*.*')
.pipe(clean());
});
gulp.task('test', function () {
'use strict';
return gulp.src(['src/**/*-spec.js'])
.pipe(karma({
configFile: 'src/karma.conf.js',
action: 'run'
}))
.on('error', function (err) {
console.log(gutil.colors.red('Error') + ': ' + err);
throw err;
});
});
gulp.task('build', ['clean', 'copy', 'uglifyJS']);
gulp.task('default', ['build']);
gulp.task('watch', function () {
gulp.watch([
'src/js/*.js',
'src/scss/*.scss',
'src/templates/*.html'
], ['build']);
});