-
Notifications
You must be signed in to change notification settings - Fork 15
/
gulpfile.js
49 lines (41 loc) · 1.08 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
const babel = require('gulp-babel')
const gulp = require('gulp')
const rimraf = require('rimraf')
const webpack = require('webpack-stream')
const lib = './lib'
const dist = './dist'
function runWebpack(prod) {
const config = require('./webpack.config.js').genWebpack(prod)
return gulp.src('src/index.js')
.pipe(webpack(config))
.pipe(gulp.dest(dist))
}
// Clear out distribution directory, make it if it does not exist.
gulp.task('clean', function (cb) {
rimraf(lib + '/*', function () {
rimraf(dist + '/*', cb)
})
})
gulp.task('build-lib', function () {
return gulp.src('src/**/*.js')
.pipe(babel({
plugins: [ 'transform-object-rest-spread' ],
presets: [ 'es2015', 'stage-1', 'react' ]
}))
.pipe(gulp.dest(lib))
})
gulp.task('build-dist', function (cb) {
runWebpack(false)
runWebpack(true)
if (cb) {
cb()
}
})
gulp.task('build', [ 'clean' ], function () {
gulp.start('build-lib')
gulp.start('build-dist')
})
// Watch Files For Changes
gulp.task('watch', function () {
gulp.watch('src/**/*.js', [ 'build-lib', 'build-dist' ])
})