-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
63 lines (58 loc) · 1.7 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
const gulp = require('gulp');
const objAssign = require('lodash.assign');
const paths = require('./configs/paths');
/**
* @return gulp task
* @param taskName {string} name of task
* @param path {string} path to file with code of task
* @param options {object=} object with custom options of task
*/
function lazyRequireTask(taskName, path, options = {}) {
objAssign(options, { taskName });
gulp.task(taskName, (callback) => {
const task = require(path).call(this, options);
return task(callback);
});
}
/** common tasks */
lazyRequireTask('lint-style', './configs/style/style-lint.js');
lazyRequireTask('assembly-style', './configs/style/style-assembly.js');
lazyRequireTask('assembly-js', './configs/js/js-assembly.js', {
src: [`${paths.src.js.folder}index.js`]
});
lazyRequireTask('assembly-view', './configs/view/view-assembly.js');
/** Tasks for development */
lazyRequireTask('set-watch', './configs/set-watch.js');
lazyRequireTask('server', './configs/server', {
src: paths.build.folder,
notify: false,
startPage: 'ui.html'
});
/** Modified dev */
gulp.task('dev',
gulp.series('set-watch',
gulp.parallel('assembly-js', 'assembly-view',
gulp.series('lint-style', 'assembly-style')
)
)
);
/** Tasks for production */
lazyRequireTask('clean-prod', './configs/clean.js', {
src: paths.prod.folder
});
gulp.task('prod', function (cb) {
let wrapperCb = function(feedback){
if(feedback){
process.exit(1);
}
cb(feedback);
};
gulp.series('clean-prod',
gulp.parallel('assembly-js', 'assembly-view',
gulp.series('lint-style', 'assembly-style')
)
)(wrapperCb);
}
);
/** Task by default */
gulp.task('default', gulp.series('dev', 'server'));