This repository has been archived by the owner on Nov 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
86 lines (73 loc) · 2.01 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
83
84
85
86
var gulp = require('gulp');
var beep = require('beepbeep')
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
var uglify = require('gulp-uglifyjs');
var sass = require('gulp-ruby-sass');
var livereload = require('gulp-livereload');
var onError = function (err) {
beep([0, 0, 0]);
gutil.log(gutil.colors.green(err));
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////
////////// WEBSITE TASKS
//////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// JS
gulp.task('uglifyjs', function() {
return gulp.src([
'./bower_components/jquery/dist/jquery.min.js',
'./js/main.js'
])
.pipe(plumber({
errorHandler: onError
}))
.pipe(uglify('app.js', {
compress: false
}))
.pipe(gulp.dest('./js/'))
.pipe(livereload());
});
// Sass
gulp.task('sass', function() {
return gulp.src([
'./scss/app.scss'
])
.pipe(plumber({
errorHandler: onError
}))
.pipe(sass({
style: 'compressed',
cacheLocation: './cache/.sass-cache'
}))
.pipe(gulp.dest('./css/'))
.pipe(livereload());
});
// HTML
gulp.task('html', function() {
return gulp.src([
'./index.html'
])
.pipe(livereload());
});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////
////////// WATCH AND BUILD TASKS
//////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Primary task to watch other tasks
gulp.task('yo', function() {
// LiveReload
livereload.listen();
// Watch JS
gulp.watch('./js/main.js', ['uglifyjs']);
// Watch Sass
gulp.watch(['./scss/_mixins.scss', './scss/_styles.scss', './scss/app.scss'], ['sass']);
// Watch HTML and livereload
gulp.watch('./index.html', ['html']);
});
// Manually build all
gulp.task('build', function() {
gulp.start('uglifyjs', 'sass');
});