-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgulpfile.js
66 lines (59 loc) · 1.88 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
var gulp = require('gulp'),
path = require('path'),
umd = require('gulp-umd'),
gutil = require('gulp-util'),
babel = require('gulp-babel'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
runSequence = require('run-sequence'),
gulpJsdoc2md = require('gulp-jsdoc-to-markdown');
var libDir = 'lib',
moduleName = 'pixiPianoRoll',
moduleNameJS = moduleName + '.js';
gulp.task('ES6ToES5UMD', function() {
var getModuleName = function() {
return moduleName;
};
return gulp.src(path.join(libDir, moduleNameJS))
.pipe(babel({
presets: ['es2015']
}))
.pipe(umd({
exports: getModuleName,
namespace: getModuleName,
dependencies: function() {
return [
{name: 'pixi.js', global: 'PIXI', param: 'pixi'},
{name: 'teoria'},
{name: 'musical-scale-colors', global: 'musicalScaleColors', param: 'musicalScaleColors'}
];
}
}))
.pipe(gulp.dest('dist'));
});
gulp.task('minify', function() {
return gulp.src(path.join('dist', moduleNameJS))
.pipe(uglify())
.pipe(rename(function(file) {
file.extname = '.min.js';
}))
.pipe(gulp.dest('dist'));
});
gulp.task('docs', function(){
return gulp.src('lib/*.js')
.pipe(gulpJsdoc2md())
.on('error', function(err){
gutil.log(gutil.colors.red('documentation generation failed'), err.message);
})
.pipe(rename(function(path){
path.basename = 'README';
path.extname = '.md';
}))
.pipe(gulp.dest('.'));
});
gulp.task('watch', function() {
gulp.watch(path.join(libDir, '*.js'), ['ES6ToES5UMD']);
});
gulp.task('default', function(cb) {
runSequence('ES6ToES5UMD', 'minify', 'docs', cb);
});