forked from andrejewski/himalaya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
52 lines (45 loc) · 1.22 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
import '@babel/polyfill'
import 'source-map-support/register'
import del from 'del'
import gulp from 'gulp'
import babel from 'gulp-babel'
import sourcemaps from 'gulp-sourcemaps'
import babelify from 'babelify'
import source from 'vinyl-source-stream'
import browserify from 'browserify'
import buffer from 'vinyl-buffer'
gulp.task('cleanLib', () => {
return del(['lib'], {force: true})
})
gulp.task('cleanDist', () => {
return del(['dist'], {force: true})
})
gulp.task('buildSrc', gulp.series('cleanLib', () => {
return gulp
.src(['src/**/*.js'])
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('lib'))
}))
gulp.task('buildDist', gulp.series('cleanDist', () => {
const options = {
entries: ['index.js'],
debug: false,
basedir: 'src',
standalone: 'himalaya'
}
return browserify(options)
.transform(babelify)
.bundle()
.pipe(source('himalaya.js'))
.pipe(buffer())
.pipe(sourcemaps.init({
// loads map from browserify file
loadMaps: true
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('docs/dist'))
}))
gulp.task('build', gulp.series('cleanLib', 'buildSrc', 'buildDist'))
gulp.task('default', gulp.series('build'))