This repository has been archived by the owner on Jun 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.babel.js
74 lines (67 loc) · 1.73 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
70
71
72
73
74
/*
* This file is part of the serializerjs package.
*
* (c) HAIRCVT <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import babel from 'gulp-babel';
import browserify from 'browserify';
import derequire from 'gulp-derequire';
import gulp from 'gulp';
import insert from 'gulp-insert';
import path from 'path';
import rename from 'gulp-rename';
import replace from 'gulp-replace';
import source from 'vinyl-source-stream';
import uglify from 'gulp-uglify';
import PACKAGE from './package.json';
const VERSION = PACKAGE.version;
const COPYRIGHT = `
/*
* serializerjs JavaScript Library v${VERSION}.
*
* (c) HAIRCVT <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Date: ${new Date().toISOString()}
*/
`;
gulp.task('compile', () => {
return gulp
.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'))
;
});
gulp.task('browserify', () => {
const stream = browserify({
builtins: {
_process: true,
},
entries: 'lib/serializerjs.js',
standalone: 'serializerjs',
})
.exclude('xmlhttprequest')
.ignore('_process')
.bundle()
;
return stream
.pipe(source('serializerjs.js'))
.pipe(derequire())
.pipe(insert.prepend(COPYRIGHT))
.pipe(gulp.dest('./dist'))
;
});
gulp.task('minify', () => {
return gulp
.src('dist/serializerjs.js')
.pipe(uglify())
.pipe(insert.prepend(COPYRIGHT))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('./dist'))
;
});