forked from brianpkelley/md-color-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
125 lines (97 loc) · 3.5 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
114
115
116
117
118
119
120
121
122
123
124
125
var gulp = require('gulp'),
debug = require('gulp-debug'),
seq = require('run-sequence'),
streamqueue = require('streamqueue'),
closure = require('gulp-jsclosure'),
less = require('gulp-less'),
uglify = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps'),
minifyCss = require('gulp-minify-css'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
templateCache = require('gulp-angular-templatecache'),
ngAnnotate = require('gulp-ng-annotate'),
autoprefix = require('gulp-autoprefixer'),
livereload = require('gulp-livereload'),
del = require('del');
var moduleName = 'mdColorPicker';
var paths = {
demo: 'demo',
dist: 'dist/',
src: {
less: ['src/less/*.less'],
templates: ['src/templates/*.tpl.html'],
js: ['src/js/*.js']
}
}
/*====================================================================
= Compile and minify less and css =
====================================================================*/
gulp.task('less', function(done) {
streamqueue({ objectMode: true },
gulp.src(paths.src.less)
)
.pipe(debug({title: 'LESS: '}))
.pipe(less({strictMath: true}))
.pipe(concat(moduleName + '.css'))
.pipe(autoprefix({browsers: ['> 1%'], cascade: true}))
.pipe(gulp.dest(paths.dist))
.pipe(rename({ extname: '.min.css' }))
.pipe(minifyCss())
.pipe(gulp.dest(paths.dist))
.on('end', done);
});
/*====================================================================
= Compile and minify js generating source maps =
====================================================================*/
// - Orders ng deps automatically
// - Precompile templates to ng templateCache
gulp.task('js', function(done) {
streamqueue({ objectMode: true },
gulp.src(paths.src.js),
gulp.src(paths.src.templates).pipe(templateCache({ module: moduleName }))
)
.pipe(debug({title: 'JS: '}))
//.pipe(sourcemaps.init())
.pipe(concat(moduleName + '.js'))
//.pipe(sourcemaps.write('.'))
.pipe(closure(['angular', 'window', 'tinycolor']))
.pipe(ngAnnotate())
.pipe(gulp.dest(paths.dist))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(paths.dist))
.on('end', done);
});
/*===================================================================
= Watch for source changes and rebuild/reload =
===================================================================*/
gulp.task('watch', function () {
livereload.listen();
//gulp.watch(paths.src.html, ['html']);
gulp.watch(paths.src.less, ['less']);
gulp.watch(paths.src.js, ['js']);
});
gulp.task('livereload', function () {
gulp.src(path.join(paths.demo, '*.html'));
});
/*=========================================
= Clean dest folder =
=========================================*/
gulp.task('clean', function (cb) {
return del([paths.dist + '/**/*']);
});
/*======================================
= Build Sequence =
======================================*/
gulp.task('build', function(done) {
var tasks = ['less', 'js'];
seq('clean', tasks, done);
});
/*====================================
= Default Task =
====================================*/
gulp.task('default', function(done){
var tasks = ['watch'];
seq('build', tasks, done);
});