-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
46 lines (40 loc) · 1.12 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
/* Created by tommyZZM.OSX on 2018/5/22. */
'use strict';
const gulp = require('gulp');
const babel = require('gulp-babel');
const mocha = require('gulp-mocha');
const babelrc = _ => ({
presets: [["@babel/preset-env", {
loose: false,
targets: {
"node": "8.0"
},
exclude: [
"transform-block-scoping",
"transform-modules-commonjs"
]
}]],
plugins: [
["@babel/plugin-proposal-decorators", {
legacy: true
}],
"@babel/plugin-proposal-object-rest-spread",
["@babel/plugin-transform-modules-commonjs", {
strict: false
}],
"@babel/plugin-proposal-class-properties"
]
});
gulp.task('build', _ => {
return gulp.src(['./src/**/*.js'])
.pipe(babel(babelrc()))
.pipe(gulp.dest('./lib'))
})
gulp.task('test', _ => {
return gulp.src(['./test/test.js', './test/test.*.js'], {read: false, allowEmpty: true})
.pipe(mocha({reporter: 'spec'}))
})
gulp.task('build-then-test', gulp.series(['build', 'test']))
gulp.task('build-watch', gulp.series(['build-then-test'], _ => {
return gulp.watch(['./src/**/*.js', './test/**/*.js'], gulp.series(['build-then-test']))
}))