-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
90 lines (73 loc) · 2.81 KB
/
gulpfile.js
File metadata and controls
90 lines (73 loc) · 2.81 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//////////////////////
// GLOBAL VARIABLES
//////////////////////
let gulp = require('gulp');
let gutil = require("gulp-util");
let yaml = require('js-yaml');
let fs = require('fs');
let conf = yaml.load(fs.readFileSync('./gulp/config.yml', 'utf8'));
let browserSync = require('browser-sync').create();
let plugins = require('gulp-load-plugins')();
let exec = require('child_process').exec;
//////////////////////
// INDIVIDUAL TASKS
//////////////////////
require('./gulp/gulp-args')(gulp, conf, errorHandler);
require('./gulp/gulp-js')(gulp, plugins, conf, errorHandler);
require('./gulp/gulp-global-scss')(gulp, plugins, conf, errorHandler);
require('./gulp/gulp-scss')(gulp, plugins, conf, errorHandler);
require('./gulp/gulp-font')(gulp, plugins, conf, errorHandler);
require('./gulp/gulp-webpack')(gulp, plugins, conf, errorHandler);
require('./gulp/gulp-img')(gulp, plugins, conf, errorHandler);
require('./gulp/gulp-cubex-serve')(gulp, exec, conf, errorHandler);
require('./gulp/gulp-watcher')(gulp, browserSync, conf, errorHandler);
require('./gulp/gulp-browser-sync')(gulp, browserSync, conf, errorHandler);
require('./gulp/gulp-browser-reload')(gulp, browserSync, conf, errorHandler);
require('./gulp/gulp-browser-sync-proxy')(gulp, browserSync, conf, errorHandler);
//////////////////////////////
// FULL GULP TASKS
//////////////////////////////
// # gulp - compiles everything once
gulp.task('default', gulp.series('args', gulp.parallel('js', 'font', 'global-scss', 'scss', 'webpack')));
// # gulp watch - compiles everything and then watch's all assets for changes
gulp.task('watch', gulp.parallel('default', 'watcher'));
// # gulp cubex - Compile then start cubex server
gulp.task('cubex', gulp.series('default', 'cubex-serve'));
// # gulp cubex-watch - Compile then start cubex server and watch for changes
gulp.task('cubex-watch', gulp.series('cubex-serve', 'watch'));
// # gulp cubex-reload - Same as above except will reload the browser after each compile
gulp.task('cubex-reload', gulp.series('cubex-serve', 'browser-sync-proxy', 'watch'));
//////////////////////////////
// Error Handler Functions
//////////////////////////////
function readTextFile() {
let data = null;
fs.readFile(
conf.gulp.errorLog,
"utf-8",
function (err, _data) { data = _data; }
);
return data;
}
function logError(origin, log) {
let src = require('stream').Readable({objectMode: true});
src._read = function () {
console.log('//////////////////// ERROR ///////////////////');
this.push(
new gutil.File(
{
cwd: "",
base: "",
path: conf.gulp.errorLog,
contents: new Buffer(log)
}
)
);
this.push(null);
};
return src
}
function errorHandler(error) {
logError(readTextFile(), JSON.stringify(error)).pipe(gulp.dest('./'));
return true;
}