-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
105 lines (95 loc) · 3.45 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// First, we'll just include gulp itself.
const gulp = require('gulp');
// Include Our Plugins
const jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
terser = require('gulp-terser'),
babel = require('gulp-babel');
const reporterFn = function (results, data, opts = {}) {
const errLen = results.filter(q => q.error.code[0] == 'E').length,
warnLen = results.filter(q => q.error.code[0] == 'W').length;
let str = '',
prevfile;
// opts = opts || {};
results.forEach(function (result) {
var file = result.file;
var error = result.error;
if (prevfile && prevfile !== file) {
str += "\n";
}
prevfile = file;
if (error.code[0] == 'E') {
str += 'ERR: ';
} else if (error.code[0] == 'W' && error.reason != 'Missing semicolon.') {
str += 'WARN: ';
} else if (error.code[0] == 'W' && error.reason == 'Missing semicolon.') {
str += 'Semicolon: ';
}
// str += error.code[0]=='E'?chalk.red('ERR:'):chalk.yellow("WARN:")
str += `${file}: line ${error.line}, col ${error.character} - ${error.reason}`;
// str += file + ': line ' + error.line + ', col ' + error.character + ', ' + error.reason + 'FULL ERR:' + JSON.stringify(error);
if (opts.verbose) {
str += ' (' + error.code + ')';
}
str += '\n';
});
if (str) {
console.log(`${str}\n ${errLen} ${"error" + (errLen === 1 ? '' : 's')}, ${warnLen} ${"warning" + (warnLen === 1 ? '' : 's')}`)
// console.log(str + "\n" + len + ' error' + ((len === 1) ? '' : 's'));
}
// console.log('NOT SURE WHERE THIS GOES!')
}
// Lint Task
gulp.task('lint', function () {
let alreadyRan = false,
semisDone = false;
return gulp.src(['bulmabox.js'])
// .pipe(th2.obj((file, enc, cb) => {
// if (!alreadyRan) {
// drawTitle('Front-End Linting');
// alreadyRan = true;
// }
// // jsStart = file._contents.toString('utf8').length;
// return cb(null, file);
// }))
.pipe(jshint({
esversion: 8
}))
.pipe(jshint.reporter(reporterFn));
});
// Concatenate & Minify JS
gulp.task('scripts', function () {
return gulp.src(['bulmabox.js'])
// .pipe(concat('allCust.js'))
// .pipe(iife())
// .pipe(gulp.dest('public/js'))
.pipe(babel({
presets: [
[
"@babel/preset-env",
{
useBuiltIns: "entry",
corejs: 3,
targets: {
firefox: "64", // or whatever target to choose .
},
}
]
]
}))
.pipe(terser())
// .pipe(concat('bulm.js'))
.pipe(rename('bulmabox.min.js'))
.pipe(gulp.dest('.'));
});
//start mongod -dbpath "d:\\data\\mongo\\db
// Watch Files For Changes
gulp.task('watch', function () {
// let alreadyRan = false;
// drawTitle('Watching Front-End scripts, Back-End Scripts, and CSS', true)
gulp.watch(['bulmabox.js'], gulp.series('lint', 'scripts'));
});
//task to simply create everything without actually watching or starting the DB
gulp.task('render', gulp.series('lint', 'scripts'))
// Default Task
gulp.task('default', gulp.series('lint', 'scripts', 'watch'));