Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
96 lines (71 loc) · 2.56 KB
/
Copy pathgulpfile.js
File metadata and controls
96 lines (71 loc) · 2.56 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
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.paginator",
appDescription : "A jQuery pagination plugin for easy and quick pagination of items inside an element.",
developerName : "JOLD Interactive; Jurgen Oldenburg",
developerURL : "https://www.jold.nl",
background : "#FFFFFF",
url : "https://github.com/joldnl/jquery.jold.paginator",
},
// ----- Build task options ----- //
build : {
destination : {
js : './',
}
},
// ----- JavaScript task options ----- //
js : {
files : './jquery.jold.paginator.js',
file : './jquery.jold.paginator.js',
destination : './',
includes : [
'./jquery.jold.paginator.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.paginator.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, gulp.series(options.watch.run()[ index ]) );
});
});