forked from IanShoe/angular-message-center
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
89 lines (77 loc) · 2.14 KB
/
gulpfile.js
File metadata and controls
89 lines (77 loc) · 2.14 KB
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
var concat = require('gulp-concat');
var del = require('del');
var es = require('event-stream');
var gulp = require('gulp');
var html2js = require('gulp-ng-html2js');
var minifyCSS = require('gulp-minify-css');
var minifyHtml = require('gulp-minify-html');
var ngAnnotate = require('gulp-ng-annotate');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var pkg = {
name: 'message-center',
bower: 'bower_components/',
dist: 'dist',
build: 'build'
};
pkg.paths = {
bowerDirectory: 'bower_components',
bowerFile: 'bower.json',
dist: {
css: pkg.dist + '/css',
js: pkg.dist + '/js'
},
js: ['src/js/*.js'],
css: ['src/css/*.scss'],
templates: ['src/html/*.html']
};
gulp.task('clean', function() {
return del([pkg.dist]);
});
gulp.task('clean-js', function() {
return del([pkg.paths.dist.js]);
});
gulp.task('clean-css', function() {
return del([pkg.paths.dist.css]);
});
gulp.task('build-js', ['clean-js'], function() {
var templateStream = gulp.src(pkg.paths.templates)
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(html2js({
moduleName: pkg.name + '.templates',
prefix: 'templates/message-center/',
stripPrefix: 'src/html/'
}));
var jsStream = gulp.src(pkg.paths.js);
return es.merge(templateStream, jsStream)
.pipe(ngAnnotate())
.pipe(concat(pkg.name + '.js'))
.pipe(gulp.dest(pkg.paths.dist.js))
.pipe(rename(pkg.name + '.min.js'))
.pipe(uglify())
.pipe(gulp.dest(pkg.paths.dist.js));
});
gulp.task('build-css', ['clean-css'], function() {
return gulp.src(pkg.paths.css)
.pipe(sass({
errLogToConsole: true
}))
.pipe(rename(pkg.name + '.css'))
.pipe(gulp.dest(pkg.paths.dist.css))
.pipe(rename(pkg.name + '.min.css'))
.pipe(minifyCSS())
.pipe(gulp.dest(pkg.paths.dist.css));
});
gulp.task('watches', function() {
gulp.watch([pkg.paths.js, pkg.paths.templates], ['build-js']);
gulp.watch([pkg.paths.css], ['build-css']);
});
// Build tasks
gulp.task('build', ['build-js', 'build-css']);
// Dev tasks
gulp.task('default', ['build', 'watches']);