-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
82 lines (64 loc) · 2.25 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict'; //eslint-disable-line strict
//-------------------------------------------------------------------------------
// Requires
//-------------------------------------------------------------------------------
const gulp = require('gulp');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const jest = require('gulp-jest-iojs');
const recipe = require('gulp-recipe');
const sourcemaps = require('gulp-sourcemaps');
const util = require('gulp-util');
//-------------------------------------------------------------------------------
// Gulp Properties
//-------------------------------------------------------------------------------
const sources = {
babel: [
'src/**',
'!**/tests/**'
]
};
//-------------------------------------------------------------------------------
// Gulp Tasks
//-------------------------------------------------------------------------------
gulp.task('default', ['prod']);
gulp.task('prod', ['babel']);
gulp.task('dev', ['babel', 'lint', 'babel-watch', 'lint-watch']);
gulp.task('babel', function() {
return gulp.src(sources.babel)
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe(babel({
presets: ['es2015', 'stage-2']
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'))
.on('error', function(error) {
util.log(error);
});
});
gulp.task('lint', recipe.get('eslint', [
'src/**/*.js',
'!node_modules/**'
]));
gulp.task('test', ['lint']);
//-------------------------------------------------------------------------------
// Gulp Watchers
//-------------------------------------------------------------------------------
gulp.task('babel-watch', function() {
gulp.watch(sources.babel, ['babel']);
});
gulp.task('lint-watch', function() {
const lintAndPrint = eslint();
lintAndPrint.pipe(eslint.formatEach());
return gulp.watch('src/**/*.js', function(event) {
if (event.type !== 'deleted') {
gulp.src(event.path)
.pipe(lintAndPrint, {end: false})
.on('error', function(error) {
util.log(error);
});
}
});
});