-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
35 lines (30 loc) · 951 Bytes
/
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
'use strict'
const babel = require('gulp-babel');
const cache = require('gulp-cached');
const exec = require('child_process').exec;
const gulp = require('gulp');
const nodemon = require('gulp-nodemon');
const sourcemaps = require('gulp-sourcemaps');
gulp.task('compile', () => {
let stream = gulp.src('src/**/*.js')
.pipe(cache())
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
return stream;
});
gulp.task('watch', ['compile'], () => {
let stream = nodemon({script: 'dist/', watch: 'src', tasks: ['compile']})
.on('restart', () => {
console.log('restarted');
});
return stream;
});
gulp.task('node', ['compile'], (cb) => {
exec('node dist/', (err, stdout, stderr) => {
console.log(stdout);
console.log(stderr);
cb(err);
});
});