forked from wangweianger/web-report-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (56 loc) · 1.53 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const gulp = require('gulp')
const connect = require('gulp-connect')
const babel = require('gulp-babel')
const uglify = require('gulp-uglify')
const clean = require('gulp-clean')
const rename = require("gulp-rename");
const stripDebug = require('gulp-strip-debug');
const gutil = require('gulp-util');
gulp.task('connect', function() {
connect.server({
root: './',
port: 8080,
livereload: true
});
});
gulp.task('html', function () {
gulp.src('./test/*.html')
.pipe(connect.reload());
});
gulp.task('babel', () =>
gulp.src('./src/*.js')
.pipe(babel({
presets: ['env']
}))
.pipe(gulp.dest('./dist'))
);
gulp.task('watch', function () {
gulp.watch(['./app/*.html'], ['html']);
gulp.watch(['./src/*.js'], ['babel']);
gulp.watch(['./src/*.js'], ['html']);
});
gulp.task('default', ['connect', 'watch','babel']);
gulp.task('test', () =>
gulp.src('./src/*.js')
.pipe(gulp.dest('./dist'))
.pipe(stripDebug())
.pipe(babel({
presets: ['env']
}))
.pipe(rename({suffix: '.test'}))
.pipe(gulp.dest('./dist'))
);
gulp.task('build', () =>
gulp.src('./src/*.js')
.pipe(gulp.dest('./dist'))
.pipe(stripDebug())
.pipe(babel({
presets: ['env']
}))
.pipe(uglify({ mangle: false }))
.on('error', function (err) {
gutil.log(gutil.colors.red('[Error]'), err.toString());
})
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./dist'))
);