-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
65 lines (55 loc) · 1.63 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
65
"use strict"
const gulp = require('gulp'),
babel = require('gulp-babel'),
babelify = require('babelify'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
watchify = require('watchify'),
rename = require('gulp-rename'),
gutil = require('gulp-util'),
nodemon = require('gulp-nodemon');
const config = {
src: './client/public/js/index.js',
dest: './client/public/dist/'
};
let bundle = (bundler) => {
bundler
.bundle()
.pipe(source('bundled-app.js'))
.pipe(buffer())
.pipe(rename('bundle.js'))
.pipe(gulp.dest(config.dest))
.on('end', () => gutil.log(gutil.colors.green('Finshed compiling js!')));
}
gulp.task('client-browserify', () => {
let bundler = browserify(config.src, {
debug: true
})
.plugin(watchify)
.transform(babelify, {
presets: ['es2015', 'react']
});
bundle(bundler);
})
gulp.task('start-server', () => {
nodemon({
script: 'index.js',
ext: 'js',
ignore: ['node_modules', 'client/public/dist', 'services/dist/'],
env: { 'NODE_ENV': 'development' }
})
})
gulp.task('babel-services', () => {
return gulp.src('services/js/**/*.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('services/dist'));
});
gulp.task('watch', () => {
gulp.watch(['client/public/js/**/*.js', 'services/src/**/*.js'], ['client-browserify', 'babel-services'])
});
gulp.task('default', () => {
gulp.start('client-browserify', 'babel-services', 'start-server' ,'watch');
});