-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
61 lines (53 loc) · 1.46 KB
/
gulpfile.js
File metadata and controls
61 lines (53 loc) · 1.46 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
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
browserSync = require('browser-sync').create(),
eslint = require('gulp-eslint'),
gulpIf = require('gulp-if'),
gutil = require('gulp-util'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
watch = require('gulp-watch');
/* ---------------------/
Development Processes
/ --------------------*/
function plumberLogEnd(errTitle) {
return plumber({
errorHandler: notify.onError({
title: errTitle || 'Error running Gulp',
message: 'Error: <%= error.message %>'
})
});
}
function isEslintFixed(file) {
return file.eslint !== null && file.eslint.fixed;
}
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: '.'
},
// tunnel: true,
online: true
});
});
gulp.task('eslint', function() {
return gulp.src(['*.js', '!gulpfile.js'])
.pipe(plumberLogEnd('Error Running eslint'))
.pipe(eslint({
fix: true
}))
.pipe(eslint.format())
.pipe(gulpIf(isEslintFixed, gulp.dest('.')))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('watch', ['browserSync', 'eslint'], function() {
watch(['*.js', '!gulpfile.js'], function(event) {gulp.start('eslint');});
gulp.watch('*.html', browserSync.reload);
gulp.watch('*.css', browserSync.reload);
});
/* ---------------------/
Other Processes
/ --------------------*/
gulp.task('default', ['watch']);