forked from RemiAWE/ng-flat-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (58 loc) · 1.74 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
'use strict';
var es = require('event-stream');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var paths = {
src: {
html: __dirname+'/src/templates/**/*.html',
js: __dirname+'/src/js/**/*.js',
scss: __dirname+'/src/scss/**/*.scss'
},
tmp: __dirname+'/.tmp/',
dist: __dirname+'/dist/'
};
var plumberErrorHandler = {
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
};
gulp.task('js', function(){
return es.merge(getTemplatesStream(), gulp.src(paths.src.js))
.pipe($.plumber(plumberErrorHandler))
.pipe($.angularFilesort())
.pipe($.ngAnnotate())
.pipe($.concat('ng-flat-datepicker.js'))
.pipe(gulp.dest(paths.dist))
.pipe($.uglify())
.pipe($.rename('ng-flat-datepicker.min.js'))
.pipe(gulp.dest(paths.dist));
});
gulp.task('sass', function(){
return gulp.src(paths.src.scss)
.pipe($.plumber(plumberErrorHandler))
.pipe($.sass({ outputStyle: 'expanded' }))
.pipe($.autoprefixer({ browsers: ['last 2 versions'] }))
.pipe($.rename('ng-flat-datepicker.css'))
.pipe(gulp.dest(paths.dist))
.pipe($.csso())
.pipe($.rename('ng-flat-datepicker.min.css'))
.pipe(gulp.dest(paths.dist));
});
/**
* Watch
*/
gulp.task('watch', function(){
$.watch(paths.src.scss, $.batch(function(events, done){
gulp.start('sass', done);
}));
$.watch([paths.src.js, paths.src.html], $.batch(function(events, done){
gulp.start('js', done);
}));
});
function getTemplatesStream() {
return gulp.src(paths.src.html)
.pipe($.angularTemplatecache('templates.js', {
module: 'ngFlatDatepicker'
}));
}