-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
48 lines (40 loc) · 1.28 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
const gulp = require('gulp');
const print = require('gulp-print');
const del = require('del');
const changed = require('gulp-changed-in-place');
const gulpIf = require('gulp-if');
const babel = require('gulp-babel');
const sourcemaps = require('gulp-sourcemaps');
const debounce = require('lodash').debounce;
const gzip = require('gulp-gzip');
gulp.task('clean', done =>
del(['api/**/*', '.cache/**/*'], done));
gulp.task('copy', () =>
gulp.src(['src/**/*'], {follow: /* symlinks */ true})
.pipe(/* only */ changed({firstPass: true}))
.pipe(gulp.dest('api')));
gulp.task('gzip', () =>
gulp.src(['src/public/**/*.*'])
.pipe(gzip())
.pipe(gulp.dest('api/public')));
gulp.task('babel', done =>
gulp.src(['src/**/*.js', '!src/public/**/*'], {follow: true})
.pipe(sourcemaps.init())
.pipe(babel(/* .babelrc */))
.pipe(sourcemaps.write({
includeContent: false,
sourceRoot: 'src'
}))
.pipe(gulp.dest('api')));
gulp.task('watch', () =>
gulp.watch('src', {followSymlinks: true}, debounce(gulp.series(
'copy', 'babel'), 2000)));
gulp.task('build',
gulp.series('clean', 'copy', 'babel', 'gzip'));
gulp.task('default',
gulp.series('build', 'watch'));
gulp.task('test', () => {
return gulp.src('./**/*.*')
.pipe(print(p => 'file:' + p))
.pipe(gulp.dest('.'));
});