-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathgulpfile.js
72 lines (62 loc) · 2.48 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
import gulp from 'gulp';
import browserSync from 'browser-sync';
import { filePaths } from './gulp/config/paths.js';
/**
* Импорт задач
*/
import { copy } from './gulp/tasks/copy.js';
import { copyRootFiles } from './gulp/tasks/copy-root-files.js';
import { reset } from './gulp/tasks/reset.js';
import { html } from './gulp/tasks/html.js';
import { server } from './gulp/tasks/server.js';
import { scss } from './gulp/tasks/scss.js';
import { javascript } from './gulp/tasks/javascript.js';
import { images } from './gulp/tasks/images.js';
import { otfToTtf, ttfToWoff, fontStyle } from './gulp/tasks/fonts.js';
import { createSvgSprite } from './gulp/tasks/create-svg-sprite.js';
import { zip } from './gulp/tasks/zip.js';
import { ftpDeploy } from './gulp/tasks/ftp-deploy.js';
const isBuild = process.argv.includes('--build');
const browserSyncInstance = browserSync.create();
const handleServer = server.bind(null, browserSyncInstance);
const handleHTML = html.bind(null, isBuild, browserSyncInstance);
const handleSCSS = scss.bind(null, isBuild, browserSyncInstance);
const handleJS = javascript.bind(null, !isBuild, browserSyncInstance);
const handleImages = images.bind(null, isBuild, browserSyncInstance);
/**
* Наблюдатель за изменениями в файлах
*/
function watcher() {
gulp.watch(filePaths.watch.static, copy);
gulp.watch(filePaths.watch.html, handleHTML);
gulp.watch(filePaths.watch.scss, handleSCSS);
gulp.watch(filePaths.watch.js, handleJS);
gulp.watch(filePaths.watch.images, handleImages);
}
/**
* Последовательная обработка шрифтов
* */
const fonts = gulp.series(otfToTtf, ttfToWoff, fontStyle);
/**
* Параллельные задачи в режиме разработки
* */
const devTasks = gulp.parallel(copy, copyRootFiles, createSvgSprite, handleHTML, handleSCSS, handleJS, handleImages);
/**
* Основные задачи
* */
const mainTasks = gulp.series(fonts, devTasks);
/**
* Построение сценариев выполнения задач
* */
const dev = gulp.series(reset, mainTasks, gulp.parallel(watcher, handleServer));
const build = gulp.series(reset, mainTasks);
const deployZIP = gulp.series(reset, mainTasks, zip);
const deployFTP = gulp.series(reset, mainTasks, ftpDeploy);
/**
* Выполнение сценария по умолчанию
* */
gulp.task('default', dev);
/**
* Экспорт сценариев
* */
export { dev, build, deployZIP, deployFTP, createSvgSprite };