-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
81 lines (64 loc) · 2.12 KB
/
Copy pathgulpfile.babel.js
File metadata and controls
81 lines (64 loc) · 2.12 KB
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
//-------------------------------------------------------------------------------
// Requires
//-------------------------------------------------------------------------------
import gulp from 'gulp';
import babel from 'gulp-babel';
import eslint from 'gulp-eslint';
import recipe from 'gulp-recipe';
import sourcemaps from 'gulp-sourcemaps';
import util from 'gulp-util';
//-------------------------------------------------------------------------------
// Gulp Properties
//-------------------------------------------------------------------------------
const sources = {
babel: [
'src/**',
'!**/tests/**'
],
eslint: [
'**/*.js',
'!dist/**',
'!node_modules/**'
]
};
//-------------------------------------------------------------------------------
// Gulp Tasks
//-------------------------------------------------------------------------------
gulp.task('default', ['prod']);
gulp.task('prod', ['babel']);
gulp.task('dev', ['babel', 'lint', 'babel-watch', 'lint-watch']);
gulp.task('babel', () => {
return gulp.src(sources.babel)
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe(babel({
presets: ['es2015', 'stage-1', 'stage-2']
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'))
.on('error', (error) => {
util.log(error);
});
});
gulp.task('lint', recipe.get('eslint', sources.eslint));
gulp.task('test', ['lint']);
//-------------------------------------------------------------------------------
// Gulp Watchers
//-------------------------------------------------------------------------------
gulp.task('babel-watch', () => {
gulp.watch(sources.babel, ['babel']);
});
gulp.task('lint-watch', () => {
const lintAndPrint = eslint();
lintAndPrint.pipe(eslint.formatEach());
return gulp.watch(sources.eslint, (event) => {
if (event.type !== 'deleted') {
gulp.src(event.path)
.pipe(lintAndPrint, {end: false})
.on('error', (error) => {
util.log(error);
});
}
});
});