forked from nk-o/video-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
69 lines (63 loc) · 1.46 KB
/
gulpfile.babel.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
const gulp = require('gulp');
const $ = require('gulp-load-plugins')();
const del = require('del');
const named = require('vinyl-named');
const webpack = require('webpack-stream');
const data = require('json-file').read('./package.json').data;
function getHeader() {
return `/*!
* Name : Video Worker
* Version : ${data.version}
* Author : ${data.author}
* GitHub : ${data.homepage}
*/
`;
}
/**
* Error Handler for gulp-plumber
*/
function errorHandler(err) {
console.error(err);
this.emit('end');
}
/**
* Clean Task
*/
gulp.task('clean', () => del(['dist']));
/**
* JS Task
*/
gulp.task('js', () => {
return gulp.src(['src/*.js', '!src/*.esm.js'])
.pipe($.plumber({ errorHandler }))
.pipe(named())
.pipe(webpack({
module: {
loaders: [
{
test: /\.js$/,
use: [{
loader: 'babel-loader',
}],
},
],
},
}))
.pipe($.header(getHeader()))
.pipe(gulp.dest('dist'))
.pipe($.rename({ suffix: '.min' }))
.pipe($.uglify({
output: {
comments: /^!/,
},
}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
/**
* Build (default) Task
*/
gulp.task('build', (cb) => {
$.sequence('clean', 'js', cb);
});
gulp.task('default', ['build']);