-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
96 lines (71 loc) · 2.57 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
// -------------------------------------
// Gulpfile
// -------------------------------------
// Available tasks:
// `gulp`
// `gulp build`
// -------------------------------------
var gulp = require('gulp'),
concat = require('gulp-concat'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
minifyjs = require('gulp-uglify');
var options = {
// ----- Manifest details ----- //
metadata : {
appName : "jquery.jold.js-load-video",
appDescription : "A jQuery plugin that only loads youtube and vimeo video's after clicking, for better performance",
developerName : "JOLD Interactive; Jurgen Oldenburg",
developerURL : "https://www.jold.nl",
background : "#FFFFFF",
url : "https://github.com/joldnl/jquery.jold.js-load-video",
},
// ----- Build task options ----- //
build : {
destination : {
js : './',
}
},
// ----- JavaScript task options ----- //
js : {
files : './jquery.jold.js-load-video.js',
file : './jquery.jold.js-load-video.js',
destination : './',
includes : [
'./jquery.jold.js-load-video.js',
],
},
// ----- Watch task options ----- //
watch : {
files : function() {
return [
options.js.files,
]
},
run : function() {
return [
[ 'default' ],
]
}
}
};
// -------------------------------------
// Task: Process Javascript
// -------------------------------------
gulp.task( 'default', function () {
return gulp.src( options.js.includes )
.pipe( plumber() ) // Prevent pipe breaking from errors
.pipe( concat( 'jquery.jold.js-load-video.js' ) ) // Concatinate all javascript files into one file
.pipe( minifyjs() ) // Minify and clean up javascript files
.pipe( rename( { suffix: '.min' } ) ) // Add .min prefix to filename
.pipe( gulp.dest( options.build.destination.js ) ); // Write files to dist folder
});
// -------------------------------------
// Task: Watch changes in source fils
// -------------------------------------
gulp.task( 'watch', function() {
var watchFiles = options.watch.files();
watchFiles.forEach( function( files, index ) {
gulp.watch( files, options.watch.run()[ index ] );
});
});