-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
72 lines (64 loc) · 1.82 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
'use strict';
var fs = require('fs');
var pkg = JSON.parse( fs.readFileSync('./package.json') );
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var plugins = require('gulp-load-plugins')();
var gutil = require('gulp-util');
var shell = require('gulp-shell');
var size = require('gulp-check-filesize');
var jshint = require('gulp-jshint');
var rename = require('gulp-rename');
var insert = require('gulp-insert');
var build = {
filename: 'rekord-debug.js',
minified: 'rekord-debug.min.js',
output: './build/',
include: [
'./src/debug.js'
]
};
var comments = [
"/*", pkg.name, pkg.version, '-', pkg.description, 'by', pkg.author, "*/\n"
];
var executeMinifiedBuild = function(props)
{
return function() {
return gulp
.src( props.output + props.filename )
.pipe( rename( props.minified ) )
.pipe( sourcemaps.init() )
.pipe( plugins.uglify().on('error', gutil.log) )
.pipe( insert.prepend( comments.join(' ') ) )
.pipe( sourcemaps.write('.') )
.pipe( size({enableGzip: true}) )
.pipe( gulp.dest( props.output ) )
;
};
};
var executeBuild = function(props)
{
return function() {
return gulp
.src( props.include )
.pipe( plugins.concat( props.filename ) )
.pipe( insert.prepend( comments.join(' ') ) )
.pipe( size({enableGzip: true}) )
.pipe( gulp.dest( props.output ) )
.pipe( jshint() )
.pipe( jshint.reporter('default') )
.pipe( jshint.reporter('fail') )
;
};
};
gulp.task('lint', function() {
return gulp
.src( build.output + build.filename )
.pipe( jshint() )
.pipe( jshint.reporter('default') )
.pipe( jshint.reporter('fail') )
;
});
gulp.task( 'js', executeBuild( build ) );
gulp.task( 'js:min', ['js'], executeMinifiedBuild( build ) );
gulp.task( 'default', ['js:min']);