-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgulpfile.js
86 lines (70 loc) · 1.72 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'),
sass = require('gulp-sass'),
gutil = require('gulp-util'),
plumber = require('gulp-plumber'),
chalk = require('chalk'),
runSequence = require('run-sequence'),
del = require('del');
var sourceFolder = 'src',
distFolder = 'dist';
var paths = {
source: {
app: sourceFolder,
html: sourceFolder + '/*.html',
image: sourceFolder + '/images/*.png',
stylesheet: sourceFolder + '/sass/*.sass'
},
destination: {
app: distFolder,
html: distFolder + '/',
image: distFolder + '/images/',
stylesheet: distFolder + '/css/'
}
};
gulp.task('clean', function () {
return del([paths.destination.app]);
});
gulp.task('html', function () {
return gulp.src(paths.source.html)
.pipe(gulp.dest(paths.destination.html));
});
gulp.task('image', function () {
return gulp.src(paths.source.image)
.pipe(gulp.dest(paths.destination.image));
});
gulp.task('sass', function () {
return gulp.src(paths.source.stylesheet)
.pipe(plumber({
errorHandler: reportError
}))
.pipe(sass())
.pipe(gulp.dest(paths.destination.stylesheet));
});
var reportError = function (error) {
gutil.beep();
var report = '',
chalk = gutil.colors.white.bgRed;
report += chalk('TASK:') + ' [' + error.plugin + ']\n';
report += chalk('PROB:') + ' ' + error.message + '\n';
if (error.lineNumber) {
report += chalk('LINE:') + ' ' + error.lineNumber + '\n';
}
if (error.fileName) {
report += chalk('FILE:') + ' ' + error.fileName + '\n';
}
console.error(report);
this.emit('end');
};
gulp.task('watch', function () {
gulp.watch(paths.source.html, ['html']);
gulp.watch(paths.source.stylesheet, ['sass']);
});
gulp.task('default', function () {
runSequence(
'clean',
'html',
'image',
'sass',
'watch'
);
});