-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
72 lines (60 loc) · 1.94 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
'use strict';
var gulp = require('gulp');
var batch = require('gulp-batch');
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var del = require('del');
var reload = browserSync.reload;
var rename = require('gulp-rename');
var templateCache = require('gulp-angular-templatecache');
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
gulp.task('default', ['build', 'watch', 'serve']);
gulp.task('clean', function() {
del('./dist/**/*');
});
gulp.task('concat', ['templates'], function() {
return gulp.src([
'./src/directives/select.js',
'./src/services/selectHelpers.js',
'./dist/angular-bootstrap-select.tpl.js'
])
.pipe(concat('angular-bootstrap-select.js'))
.pipe(gulp.dest('dist/'));
});
gulp.task('templates', function() {
return gulp.src('./templates/**/*.html')
.pipe(templateCache('angular-bootstrap-select.tpl.js', {
root: 'angular-bootstrap-select',
module: 'angular-bootstrap-select',
templateHeader: 'angular.module(\'<%= module %>\'<%= standalone %>).run([\'$templateCache\', function($templateCache) {\n ',
templateBody: '$templateCache.put(\'<%= url %>\',\n \'<%= contents %>\'\n );',
templateFooter: '\n}]);'
}))
.pipe(gulp.dest('dist/'));
});
gulp.task('min', ['concat'], function() {
return gulp.src('./dist/angular-bootstrap-select.js')
.pipe(uglify({ mangle: false }))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('./dist/'));
});
gulp.task('watch', function() {
watch(['src/**/*.js', 'templates/**/*.html'], batch(function(events, done) {
gulp.start('build', done);
}));
});
gulp.task('serve', function() {
browserSync({
server: {
baseDir: 'examples',
routes: {
'/bower_components': 'bower_components',
'/dist': 'dist'
},
directory: true
}
});
gulp.watch(['dist/**/*.js', 'examples/**/*'], {}, reload);
});
gulp.task('build', ['clean', 'min']);