-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
113 lines (92 loc) · 2.44 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
111
112
113
//==============//
// DEPENDENCIES //
//==============//
// Local dependencies.
var pkg = require('./package.json');
// Node dependencies.
var fs = require('fs');
// Third-party dependencies.
var del = require('del');
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');
var ngAnnotate = require('gulp-ng-annotate');
var concat = require('gulp-concat');
var header = require('gulp-header');
var runSequence = require('run-sequence');
var KarmaServer = require('karma').Server;
var htmlmin = require('gulp-htmlmin');
var jshint = require('gulp-jshint');
//=========//
// GLOBALS //
//=========//
//=======//
// CLEAN //
//=======//
gulp.task('clean', function (callback) {
return del('dist');
});
//=======//
// BUILD //
//=======//
gulp.task('build', function (done) {
runSequence('clean', ['build:scripts', 'build:templates'], done);
});
gulp.task('build:scripts', function () {
var headerContent = fs.readFileSync('src/scripts/header.js', 'utf8');
return gulp
.src([
'./src/scripts/module.js'
])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(concat('betsol-ng-module.js'))
.pipe(ngAnnotate({
'single_quotes': true
}))
.pipe(header(headerContent, { pkg : pkg } ))
.pipe(gulp.dest('dist/scripts'))
.pipe(uglify())
.pipe(header(headerContent, { pkg : pkg } ))
.pipe(rename('betsol-ng-module.min.js'))
.pipe(gulp.dest('dist/scripts'))
.on('error', gutil.log)
;
});
gulp.task('build:templates', function () {
var headerContent = fs.readFileSync('src/templates/header.html', 'utf8');
return gulp
.src([
'./src/templates/module.html'
])
.pipe(header(headerContent, { pkg : pkg } ))
.pipe(gulp.dest('dist/templates'))
.pipe(htmlmin({
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeRedundantAttributes: true,
caseSensitive: true
}))
.pipe(rename('module.min.html'))
.pipe(header(headerContent, { pkg : pkg } ))
.pipe(gulp.dest('dist/templates'))
.on('error', gutil.log)
;
});
//======//
// TEST //
//======//
gulp.task('test', function (done) {
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
//==============//
// DEFAULT TASK //
//==============//
gulp.task('default', function (done) {
runSequence('build', 'test', done);
});