-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.babel.js
70 lines (59 loc) · 1.94 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import config from './gulp/config';
const tBuild = (task, cb) => require('./gulp/tasks/' + task).build(cb);
const tWatch = (task) => require('./gulp/tasks/' + task).watch();
gulp.task('server', (cb) => tBuild('server', cb));
gulp.task('clear', () => tBuild('clear'));
gulp.task('sass', () => tBuild('sass'));
gulp.task('pug', () => tBuild('pug'));
gulp.task('javascript', tBuild('javascript'));
gulp.task('images', () => tBuild('images'));
gulp.task('sprite:svg', tBuild('sprite-svg/sprite-svg'));
gulp.task('sprite:png', () => tBuild('sprite-png/sprite-png'));
gulp.task('copy', tBuild('copy'));
gulp.task('index-page', () => tBuild('index/index-page'));
gulp.task('sass:watch', tWatch('sass'));
gulp.task('copy:watch', tWatch('copy'));
gulp.task('pug:watch', tWatch('pug'));
gulp.task('javascript:watch', tWatch('javascript'));
gulp.task('images:watch', tWatch('images'));
gulp.task('sprite:svg:watch', tWatch('sprite-svg/sprite-svg'));
gulp.task('sprite:png:watch', tWatch('sprite-png/sprite-png'));
gulp.task('index-page:watch', tWatch('index/index-page'));
const setmodeProd = (done) => {
config.setEnv('production');
config.logEnv();
done();
};
const setmodeDev = (done) => {
config.setEnv('development');
config.logEnv();
done();
};
const makeBuild = (mode) => {
const setMode = mode === 'prodcution' ? setmodeProd : setmodeDev;
return gulp.series(
setMode,
'clear',
gulp.parallel('sprite:svg', 'sprite:png'),
gulp.parallel('sass', 'javascript'),
'pug',
gulp.parallel('images', 'copy', 'index-page')
);
};
gulp.task('build', makeBuild('prodcution'));
gulp.task('build:development', makeBuild('development'));
gulp.task(
'watch',
gulp.parallel(
'sass:watch',
'copy:watch',
'pug:watch',
'javascript:watch',
'images:watch',
'sprite:svg:watch',
'sprite:png:watch',
'index-page:watch'
)
);
gulp.task('default', gulp.series(['build:development', 'server', 'watch']));