-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgulpfile.babel.js
42 lines (36 loc) · 1.19 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
"use strict";
import gulp from 'gulp';
import uglify from 'gulp-uglify';
import grename from 'gulp-rename';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import browserify from 'browserify';
import gbabel from 'gulp-babel';
import globalShim from 'browserify-global-shim';
let src_files = './src/*.js';
let build_path = 'dst';
gulp.task('transpile', () => {
return gulp.src(src_files)
.pipe(gbabel({presets: ["es2015", "react", "stage-3"]}))
.pipe(gulp.dest('./component/'));
});
gulp.task('browserify', () => {
return browserify('./src/index.js')
.transform('babelify', {presets: ['es2015', 'react', 'stage-3']})
.transform(globalShim.configure({
'react': 'React'
}))
.bundle()
.pipe(source('react-github-fork-ribbon.js'))
.pipe(gulp.dest(build_path))
.pipe(buffer())
.pipe(uglify())
.pipe(grename('react-github-fork-ribbon.min.js'))
.pipe(gulp.dest(build_path));
});
gulp.task('watch', () => {
gulp.watch([src_files], gulp.series('build'));
});
gulp.task('build', gulp.series('transpile', 'browserify'));
gulp.task('dev', gulp.series('build', 'watch'));
gulp.task('default', gulp.series('build'));