-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
79 lines (72 loc) · 2.41 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
var plumber = require('gulp-plumber');
var wrap = require('gulp-wrap');
var declare = require('gulp-declare');
var handlebars = require('gulp-handlebars');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
gulp.task('default', ['js_libs', 'js_app', 'sass', 'template'], function(){
// browserSync.init({
// proxy: "http://theokleman.local/"
// });
gulp.watch('js/app/**/*.js', ['js_app']);
gulp.watch('sass/**/*.scss', ['sass']);
gulp.watch('templates/**/*', ['template']);
gulp
.watch([
'./js/app/**/*.js',
'./js/vendors/**/*.js',
"index.html"
])
// .on('change', browserSync.reload);
});
gulp.task('js_libs', function(){
return gulp
.src([
'js/vendors/jquery/dist/jquery.min.js',
'js/vendors/handlebars/handlebars.min.js',
'js/vendors/gsap/src/minified/TweenMax.min.js',
'js/vendors/gsap/src/minified/plugins/CSSPlugin.min.js',
])
.pipe(concat('vendors.js'))
.pipe(uglify('vendors.js'))
.pipe(gulp.dest('js/dist'))
});
gulp.task('js_app', function(){
return gulp.src(['js/app/helpers.js','js/app/**/*.js'])
.pipe(concat('app.js'))
.pipe(uglify('app.js'))
.pipe(gulp.dest('js/dist'))
});
gulp.task('sass', function(){
return gulp.src('sass/**/*.scss')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}
}))
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('css/'))
.pipe(browserSync.stream());
});
gulp.task('template', function() {
return gulp.src('templates/**/*.hbs')
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'templates',
noRedeclare: true,
}))
.pipe(concat('template.js'))
.pipe(uglify('template.js'))
.pipe(gulp.dest('js/dist'));
});