-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (49 loc) · 1.44 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
const { watch, series, parallel } = require("gulp");
const browserSync = require("browser-sync").create();
// Конфигурация
const path = require("./config/path.js");
const app = require('./config/app.js');
// Задачи
const clear = require("./task/clear.js");
const html = require("./task/html.js");
const scss = require("./task/scss.js");
const js = require("./task/js.js");
const img = require("./task/img.js");
const font = require("./task/font.js");
const favicon = require("./task/favicon.js");
// Статический сервер
const server = () => {
browserSync.init({
server: {
baseDir: path.root
}
});
}
// Отслеживание изменений
const watcher = () => {
watch(path.html.watch, html).on('all', browserSync.reload);
watch(path.scss.watch, scss).on('all', browserSync.reload);
watch(path.js.watch, js).on('all', browserSync.reload);
watch(path.img.watch, img).on('all', browserSync.reload);
watch(path.font.watch, font).on('all', browserSync.reload);
watch(path.favicon.watch, favicon).on('all', browserSync.reload);
}
const build = series(
clear,
parallel(html, scss, js, font, img, favicon)
);
const dev = series(
build,
parallel(server, watcher)
);
// Публичные задачи
exports.html = html;
exports.scss = scss;
exports.js = js;
exports.img = img;
exports.font = font;
exports.favicon = favicon;
// Сборка
exports.default = app.isProd
? build
: dev;