-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
105 lines (86 loc) · 2.55 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
/* Remove jQuery as $ so it can be used by gulp-load-plugins */
/* globals require, -$ */
var {src, dest, series,task} = require('gulp'),
args = require('yargs').argv,
del = require('del'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
ignore = require('gulp-ignore'),
runSequence = require('run-sequence'),
$ = require('gulp-load-plugins')({ lazy: true }),
config = require('./gulp.config')();
// *** Code analysis ***
async function vet(){
$.util.log('Running static code analysis.');
return src(config.alljs)
.pipe($.if(args.verbose, $.print()))
.pipe($.jscs())
.pipe($.jscs.reporter())
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish', { verbose: true }));
}
// *** cleaning tasks ***
function clean(path) {
$.util.log('Cleaning: ' + $.util.colors.blue(path));
return del(path);
}
async function cleanDist(){
await clean('./dist/*');
};
// *** CSS Compilation ***
async function copyCss() {
return src(config.css)
.pipe(concat('knetmaps.css'))
.pipe(dest(config.outputCss, {overwrite : true}));
}
// *** JS copying ***
async function copyJs() {
return src(config.js)
.pipe(concat('knetmaps.js'))
.pipe(dest(config.outputJs, {overwrite : true}))
.pipe(rename('knetmaps.min.js'))
.pipe(uglify())
.pipe(dest(config.outputJs, {overwrite : true}));
};
//*** Lib copying ***
async function copyLibs() {
return src(config.libs)
.pipe(concat('knetmaps-lib.js'))
.pipe(dest(config.outputJs, {overwrite : true}))
.pipe(rename('knetmaps-lib.min.js'))
.pipe(uglify())
.pipe(dest(config.outputJs, {overwrite : true}));
};
//*** Lib copying ***
async function copyLibsNoJquery(){
return src(config.libs)
.pipe(ignore.exclude('jquery-*.js'))
.pipe(concat('knetmaps-lib-nojquery.js'))
.pipe(dest(config.outputJs, {overwrite : true}))
.pipe(rename('knetmaps-lib-nojquery.min.js'))
.pipe(uglify())
.pipe(dest(config.outputJs, {overwrite : true}));
};
//*** Fonts copying ***
async function copyFonts() {
return src(config.fonts)
.pipe(dest(config.outputFonts, {overwrite : true}));
}
//*** Image copying ***
async function copyImages() {
return src(config.images)
.pipe(dest(config.outputImages, {overwrite : true}));
}
// create a default task and just log a message
task('help',$.taskListing)
var dev= series(
cleanDist,
copyCss,
copyJs,
copyLibs,
copyLibsNoJquery,
copyFonts,
copyImages,)
exports.optimise =dev
exports.default = task('default',series('help'))