-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
59 lines (50 loc) · 1.75 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var livereload = require('gulp-livereload');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var babel = require("gulp-babel");
// function to errors catching
function wrapPipe(taskFn) {
return function(done) {
var onSuccess = function() {
done();
};
var onError = function(err) {
done(err);
}
var outStream = taskFn(onSuccess, onError);
if(outStream && typeof outStream.on === 'function') {
outStream.on('end', onSuccess);
}
}
}
gulp.task('default', function() {
livereload.listen();
var client = ['js', 'sass'];
gulp.watch('src/js/**/*.js', client);
gulp.watch('src/sass/**/*.scss', client);
});
// compile sass
gulp.task('sass', wrapPipe(function(success, error) {
return gulp.src('./src/sass/**/*.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(concat('./style.min.css').on('error', error))
.pipe(gulp.dest('./www/css'))
.pipe(livereload());
}));
gulp.task('lib', wrapPipe(function (success, error) {
return gulp.src(['bower_components/angular/angular.min.js', 'bower_components/angular-route/angular-route.min.js', 'bower_components/angular-sanitize/angular-sanitize.min.js', 'bower_components/ngToast/dist/ngToast.min.js', 'bower_components/angular-animate/angular-animate.min.js', 'bower_components/moment/moment.js'])
.pipe(gulp.dest('./www/js/lib'))
.pipe(livereload());
}));
// task to concat and minify js
gulp.task('js', wrapPipe(function(success, error) {
return gulp.src('src/js/**/*.js')
// .pipe(concat('app.min.js').on('error', error))
// .pipe(uglify().on('error', error))
.pipe(babel())
.pipe(gulp.dest('./www/js/'))
.pipe(livereload());
}));