forked from RemiAWE/ng-flat-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
92 lines (83 loc) · 2.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
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
'use strict';
var es = require('event-stream');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var paths = {
src: {
html: __dirname+'/src/*.html',
html_template: __dirname+'/src/templates/**/*.html',
js: __dirname+'/src/js/**/*.js',
scss: __dirname+'/src/scss/**/*.scss'
},
dep: {
angular: __dirname+'/node_modules/angular/angular.js',
moment: __dirname+'/node_modules/moment/moment.js',
jmoment: __dirname+'/node_modules/moment-jalaali/build/moment-jalaali.js'
},
tmp: __dirname+'/.tmp/',
dist: __dirname+'/dist/',
demo: __dirname+'/demo/'
};
var plumberErrorHandler = {
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
};
gulp.task('html', function() {
gulp.src(paths.src.html).pipe(gulp.dest(paths.demo));
});
gulp.task('prerequisitiesJs', function(){
return gulp.src([paths.dep.angular,paths.dep.moment,paths.dep.jmoment])
.pipe($.concat('prerequisities.js'))
.pipe(gulp.dest(paths.dist))
.pipe($.uglify())
.pipe($.rename('prerequisities.min.js'))
.pipe(gulp.dest(paths.dist));
});
gulp.task('js', ['prerequisitiesJs'], function(){
return es.merge(getTemplatesStream(), gulp.src(paths.src.js))
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe($.plumber(plumberErrorHandler))
.pipe($.angularFilesort())
.pipe($.ngAnnotate())
.pipe($.concat('ng-jalaali-flat-datepicker.js'))
.pipe(gulp.dest(paths.dist))
.pipe($.uglify())
.pipe($.rename('ng-jalaali-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-jalaali-flat-datepicker.css'))
.pipe(gulp.dest(paths.dist))
.pipe($.csso())
.pipe($.rename('ng-jalaali-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_template], $.batch(function(events, done){
gulp.start('js', done);
}));
$.watch([paths.src.html], $.batch(function(events, done) {
gulp.start('html', done);
}));
});
function getTemplatesStream() {
return gulp.src(paths.src.html_template)
.pipe($.angularTemplatecache('templates.js', {
module: 'ngJalaaliFlatDatepicker'
}));
}