forked from Foxandxss/angular-toastr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (71 loc) · 2.31 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
var gulp = require('gulp');
var less = require('gulp-less');
var jshint = require('gulp-jshint');
var ngTemplates = require('gulp-angular-templatecache');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var cssnano = require('gulp-cssnano');
var del = require('del');
var stylish = require('jshint-stylish');
gulp.task('less-dev', function() {
return gulp.src('src/toastr.less')
.pipe(less())
.pipe(gulp.dest('gen'));
});
gulp.task('less-prod', function() {
return gulp.src('src/toastr.less')
.pipe(less())
.pipe(rename('angular-toastr.css'))
.pipe(gulp.dest('dist'))
.pipe(cssnano({
zindex: false
}))
.pipe(rename('angular-toastr.min.css'))
.pipe(gulp.dest('dist'));
});
gulp.task('lint', function() {
return gulp.src(['src/**/*.js', 'test/**/*_spec.js'])
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('scripts-dev', function() {
return gulp.src(['src/toastr.js', 'src/**/*.js'])
.pipe(concat('toastr.js'))
.pipe(gulp.dest('gen'));
});
gulp.task('scripts-prod', function() {
return gulp.src(['src/toastr.js', 'src/**/*.js'])
.pipe(concat('angular-toastr.js'))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(rename('angular-toastr.min.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('scripts-prod-tpls', ['template'], function() {
return gulp.src(['src/toastr.js', 'src/**/*.js', 'gen/toastr.tpl.js'])
.pipe(concat('angular-toastr.tpls.js'))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(rename('angular-toastr.tpls.min.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('template', function() {
return gulp.src('src/**/*.html')
.pipe(ngTemplates({
module: 'toastr'
}))
.pipe(rename('toastr.tpl.js'))
.pipe(gulp.dest('gen'));
});
gulp.task('watch', function() {
gulp.watch('src/**/*.js', ['lint', 'scripts-dev']);
gulp.watch('src/toastr.less', ['less-dev']);
gulp.watch('src/**/*.html', ['template']);
});
gulp.task('clean', function(cb) {
del(['dist', 'gen'], cb);
});
gulp.task('default', ['less-dev', 'scripts-dev', 'template', 'watch']);
gulp.task('production', ['less-prod', 'scripts-prod', 'scripts-prod-tpls']);
gulp.task('travis', ['less-dev', 'scripts-dev', 'template']);