forked from egbertbouman/billy-radio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
77 lines (66 loc) · 2.28 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
var gulp = require('gulp'),
del = require('del'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify');
minifyHtml = require('gulp-minify-html'),
minifyCss = require('gulp-minify-css'),
rev = require('gulp-rev'),
ngAnnotate = require('gulp-ng-annotate'),
templateCache = require('gulp-angular-templatecache'),
addsrc = require('gulp-add-src'),
useref = require('gulp-useref'),
gulpif = require('gulp-if'),
concat = require('gulp-concat'),
lazypipe = require('lazypipe'),
revReplace = require('gulp-rev-replace'),
ghPages = require('gulp-gh-pages'),
argv = require('yargs').argv;
var jsTask = lazypipe()
.pipe(addsrc.append, 'tmp/templates.js')
.pipe(concat, 'assets/js/app.js')
.pipe(ngAnnotate)
.pipe(uglify)
.pipe(rev);
var cssTask = lazypipe()
.pipe(minifyCss)
.pipe(rev);
gulp.task('clean', function () {
return del(['dist']);
});
gulp.task('jshint', function() {
return gulp.src(['app/*.js', 'assets/js/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('build-tmpls', ['clean'], function () {
return gulp.src('app/views/*.html')
.pipe(minifyHtml({quotes: true}))
.pipe(templateCache({module: 'billy-radio', root: 'app/views/'}))
.pipe(gulp.dest('tmp'));
});
gulp.task('build-js-css-html', ['build-tmpls'], function () {
return gulp.src(['index.html', 'widget.html'])
.pipe(useref())
.pipe(gulpif('*.js', jsTask()))
.pipe(gulpif('*.css', cssTask()))
.pipe(revReplace())
.pipe(addsrc('widget.js'))
.pipe(gulpif('widget.js', uglify()))
.pipe(gulp.dest('dist'));
});
gulp.task('build-img', ['clean'], function () {
return gulp.src(['assets/img/**'])
.pipe(gulp.dest('dist/assets/img'));
})
gulp.task('build-fonts', ['clean'], function () {
return gulp.src(['assets/fonts/**'])
.pipe(gulp.dest('dist/assets/fonts'));
})
gulp.task('remove-tmp', ['build-js-css-html'], function () {
return del(['tmp']);
});
gulp.task('deploy', ['default'], function() {
return gulp.src('./dist/**/*')
.pipe(ghPages({remoteUrl: argv.remoteurl}));
});
gulp.task('default', ['clean', 'jshint', 'build-tmpls', 'build-js-css-html', 'remove-tmp', 'build-img', 'build-fonts']);