-
Notifications
You must be signed in to change notification settings - Fork 94
/
gulpfile.babel.js
55 lines (48 loc) · 1.39 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
'use strict';
import gulp from 'gulp';
import babel from 'gulp-babel';
import rename from 'gulp-rename';
import clean from 'gulp-clean';
import watch from 'gulp-watch';
import plumber from 'gulp-plumber';
const LOCAL_ENV_PATH = process.env.HEXO_TAG_APLAYER_LOCAL_PATH;
const sources = ['index.es', 'lib/**/*.es', 'common/**/*.es'];
const resetExt = (path) => {
path.extname = '.js';
console.log(JSON.stringify(path))
};
gulp.task('default', ['build']);
gulp.task('build', () => {
return gulp.src(sources, {base: '.'})
.pipe(babel({
'presets': ['es2015']
}))
.pipe(rename(resetExt))
.pipe(gulp.dest('.'));
});
gulp.task('local-test', () => {
return gulp.src(sources, {base: '.'})
.pipe(babel({
'presets': ['es2015']
}))
.pipe(rename(resetExt))
.pipe(gulp.dest(LOCAL_ENV_PATH));
});
gulp.task('clean', () => {
const builds = sources.map((s) => s.replace('es', 'js'));
return gulp.src(builds, {read: false})
.pipe(clean());
});
gulp.task('watch', () => {
return watch(sources, () => {
return gulp.src(sources, {base: '.'})
.pipe(watch(sources))
.pipe(plumber(err => console.log(err.stack)))
.pipe(babel({
'presets': ['es2015']
}))
.pipe(plumber.stop())
.pipe(rename(resetExt))
.pipe(gulp.dest(LOCAL_ENV_PATH));
});
});