-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
101 lines (90 loc) · 2.53 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
'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 qunit = require('gulp-qunit');
var shell = require('gulp-shell');
var merge = require('merge-stream');
var size = require('gulp-check-filesize');
var jshint = require('gulp-jshint');
var rename = require('gulp-rename');
var insert = require('gulp-insert');
var glob = require('glob');
var build = {
filename: 'anim8js-dom.js',
minified: 'anim8js-dom.min.js',
output: './build/',
include: [
'./src/_header.js',
'./src/core.js',
'./src/Easings.js',
'./src/Attributes.js',
'./src/attribute.js',
'./src/factory.js',
'./src/Properties.js',
'./src/property.js',
'./src/AnimatorDom.js',
'./src/FactoryDom.js',
'./src/IE.js',
'./src/_footer.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') )
;
};
};
var executeTest = function(file)
{
return function() {
return gulp
.src( file )
.pipe( qunit() )
;
};
};
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']);
gulp.task( 'test', ['js'], executeTest( './test/index.html' ) );
gulp.task( 'docs', shell.task(['./node_modules/.bin/jsdoc -c jsdoc.json']));
gulp.task( 'clean', shell.task(['rm -rf build/*.js', 'rm -rf build/*.map']));