-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathgulpfile.js
63 lines (49 loc) · 1.67 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
/*-------------------------------------------------------------------------
* Include Gulp & Tools We'll Use
*
*-------------------------------------------------------------------------*/
var colors = require('colors'),
gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
pckg = require('./package.json');
var include_options = {
prefix : '@@',
basepath : '@file'
},
srcPath = 'src/defiant.js',
destPath = 'dist/';
var now = new Date(),
banner = `/*
* defiant.js [v${pckg.version}]
* ${pckg.homepage}
* Copyright (c) 2013-${now.getFullYear()} ${pckg.author.name} <${pckg.author.email}>
* License ${pckg.license}
*/`;
/*-------------------------------------------------------------------------
* Gulp HELP
*-------------------------------------------------------------------------*/
gulp.task('help', (done) => {
var str = banner.replace(/\/\*|\*\/|\*/g, '').white +
'\n----DEVELOPMENT Mode-------------------------------------------------------------'+
'\n gulp build'.cyan +'\t\tCreates a build version'.grey+
'\n gulp watch'.cyan +'\t\tWatches source files and compiles on change'.grey+
'\n----------------------------------------------------------------------------------\n';
console.log(str);
done();
});
function build() {
return gulp.src(srcPath)
.pipe($.fileInclude(include_options))
.pipe($.insert.prepend(banner))
.pipe(gulp.dest(destPath))
.pipe($.uglifyes())
.pipe($.rename({suffix: '.min'}))
.pipe($.insert.prepend(banner))
.pipe(gulp.dest(destPath))
.pipe($.size({title: 'build'}));
};
function watch() {
gulp.watch('src/*.js', build);
}
gulp.task('build', build);
gulp.task('watch', watch);