-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
65 lines (56 loc) · 1.61 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
'use strict';
var gulp = require('gulp'),
gutil = require('gulp-util'),
plumber = require('gulp-plumber'),
browserSync = require("browser-sync"),
pug = require('gulp-pug'),
cachebust = require('gulp-cache-bust'),
reload = browserSync.reload;
// Ресурсы проекта
var paths = {
styles: 'assets/source/styles/',
css: 'assets/css/',
scripts: 'assets/source/scripts/',
js: 'assets/js/',
templates: 'templates/',
img: 'assets/source/img/',
bundles: 'assets/img/',
html: './'
};
// Федеральная служба по контролю за оборотом файлов
gulp.task('watch', function(done) {
gulp.watch(paths.templates + '**/*.pug', gulp.series('pug'));
done();
});
// Шаблонизация
gulp.task('pug', function() {
return gulp.src(paths.templates + '*.pug')
.pipe(plumber({errorHandler: onError}))
.pipe(pug({pretty: true}))
.pipe(gulp.dest(paths.html));
});
// Очистка кэша для яваскрипта и ЦССа
gulp.task('cache', function() {
return gulp.src(paths.html + '*.html')
.pipe(cachebust())
.pipe(gulp.dest(paths.html))
.pipe(reload({stream: true}));
});
// Рефреш ХТМЛ-страниц
gulp.task('html', function () {
gulp.src(paths.html + '*.html')
.pipe(reload({stream: true}));
});
// Одноразовая сборка проекта
gulp.task('default', gulp.series('pug', 'cache'));
// Ошибки
var onError = function(error) {
gutil.log([
(error.name + ' in ' + error.plugin).bold.red,
'',
error.message,
''
].join('\n'));
gutil.beep();
this.emit('end');
};