-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
55 lines (48 loc) · 1.67 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
import babel from 'gulp-babel';
import babelify from 'babelify';
import browserify from 'browserify';
import buffer from 'vinyl-buffer';
import ghPages from 'gulp-gh-pages';
import gulp from 'gulp';
import derequire from 'gulp-derequire';
import gutil from 'gulp-util';
import ifElse from 'gulp-if-else';
import print from 'gulp-print';
import rimraf from 'rimraf';
import source from 'vinyl-source-stream';
import sourcemaps from 'gulp-sourcemaps';
import uglify from 'gulp-uglify';
function dist(minified) {
return browserify({entries: 'src/index.js', standalone: 'FieldKit'})
.transform(babelify)
.bundle()
.pipe(source(minified ? 'field-kit.min.js' : 'field-kit.js'))
.pipe(derequire())
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(ifElse(minified, uglify))
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
}
gulp.task('clean:lib', done => rimraf('./lib', done));
gulp.task('clean:dist', done => rimraf('./dist', done));
gulp.task('dist:not-minified', ['clean:dist'], () => dist(false));
gulp.task('dist:minified', ['clean:dist'], () => dist(true));
gulp.task('dist', ['dist:not-minified', 'dist:minified']);
gulp.task('gh-pages', ['build'], function () {
return gulp.src(['public/**/*'])
.pipe(print())
.pipe(ghPages());
});
gulp.task('move-fk-to-public', function() {
return gulp.src('dist/field-kit.js')
.pipe(gulp.dest('public/javascript'));
});
gulp.task('lib', ['clean:lib'], function () {
return gulp.src(['src/**/*.js', '!src/index.js'])
.pipe(babel())
.pipe(gulp.dest('lib'));
});
gulp.task('build', ['lib', 'dist', 'move-fk-to-public']);
gulp.task('default', ['build']);