-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
75 lines (64 loc) · 2.1 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
var fs = require('fs');
var gulp = require('gulp');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var es = require('event-stream');
var del = require('del');
var uglify = require('gulp-uglify');
var minifyHtml = require('gulp-minify-html');
var minifyCss = require('gulp-minify-css');
var templateCache = require('gulp-angular-templatecache');
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');//To prevent pipe breaking caused by errors at 'watch'
var coffee = require('gulp-coffee')
var jade = require('gulp-jade')
gulp.task('watch', ['style'], function() {
gulp.watch(['src/**/*.{js,jade,coffee,css}'], ['style']);
});
gulp.task('clean', function(cb) {
del(['dist', 'build'], cb);
});
gulp.task('coffee', function() {
return gulp.src(['src/module.coffee', 'src/services/*.coffee', 'src/directives/*.coffee'])
.pipe(concat('tmp.coffee'))
.pipe(coffee({bare: true}))
.pipe(gulp.dest('build'));
});
gulp.task('build', ['clean', 'coffee'], function() {
var buildTemplates = function () {
return gulp.src('src/templates/*.jade')
.pipe(jade())
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(templateCache({module: 'colorBrewer'}));
};
var buildLib = function(){
return gulp.src(['build/tmp.js', 'src/ui-select/select.js'])
.pipe(concat('select_without_templates.js'))
};
return es.merge(buildLib(), buildTemplates())
.pipe(plumber({
errorHandler: handleError
}))
.pipe(concat('angular-color-brewer-picker.js'))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(rename('angular-color-brewer-picker.min.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('style', ['build'], function(){
return gulp.src(['src/style.css'])
.pipe(rename('angular-color-brewer-picker.css'))
.pipe(gulp.dest('dist'))
.pipe(minifyCss())
.pipe(rename('angular-color-brewer-picker.min.css'))
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['style']);
var handleError = function (err) {
console.log(err.toString());
this.emit('end');
};