-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.babel.js
63 lines (54 loc) · 1.57 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
import gulp from 'gulp';
import path from 'path';
import gulpLoadPlugins from 'gulp-load-plugins';
const plugins = gulpLoadPlugins();
const paths = {
js: './app/**/*.js',
nonJs: './app/**/*.!(js)',
tests: './app/tests/**/*.js',
};
gulp.task('clean', () => {
return gulp.src('./dist', {
allowEmpty: true,
})
.pipe(plugins.clean());
});
gulp.task('copy', () => {
return gulp.src(paths.nonJs)
.pipe(plugins.newer('dist'))
.pipe(gulp.dest('dist'));
});
gulp.task('babel', () => {
return gulp.src(paths.js)
.pipe(plugins.newer('dist'))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.babel())
.pipe(plugins.sourcemaps.write('.', { sourceRoot: './../src' }))
.pipe(gulp.dest('dist'));
});
gulp.task('nodemon', gulp.series(gulp.parallel('copy', 'babel'), () => {
return plugins.nodemon({
script: path.join('dist/', 'app.js'),
ext: 'js',
ignore: ['node_modules/**/*.js', 'dist/**/*.js'],
tasks: ['copy', 'babel'],
});
}));
gulp.task('serve', gulp.series('clean', 'nodemon'));
gulp.task('test', gulp.series('clean', 'babel', () => {
return gulp.src(paths.tests)
.pipe(plugins.ava({ verbose: true }))
.on('error', (err) => {
console.error(err.message, err);
process.exit(1);
})
.on('end', () => console.log('completed'));
}));
gulp.task('lint', () => {
return gulp.src(['./app/**', './test/**'])
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
// Brick on failure to be super strict
.pipe(plugins.eslint.failOnError());
});
gulp.task('default', gulp.series('clean', 'babel', 'copy'));