forked from Dean177/lunch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
80 lines (69 loc) · 2.1 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
import babel from 'gulp-babel';
import del from 'del';
import eslint from 'gulp-eslint';
import gulp from 'gulp';
import util, { PluginError } from 'gulp-util';
import mocha from 'gulp-mocha';
import sequence from 'gulp-sequence';
import nodemon from 'gulp-nodemon';
import webpack from 'webpack';
import webpackProdConfig from './webpack.config.prod';
gulp.task('make', sequence(['clean', 'static-assets', 'make-server', 'prod-webpack']));
gulp.task('start', sequence(['static-assets', 'make-server', 'watch', 'app-server']));
gulp.task('run-tests', sequence(['make-server', 'test', 'lint']));
gulp.task('test', () => {
return gulp.src(['out/tests/**/*.spec.js'], { read: false }).pipe(mocha());
});
gulp.task('app-server', () => {
nodemon({
script: 'out/server/index.js',
ext: 'js',
"verbose": false,
"watch": ["out/server/**/*", "out/shared/**/*"],
"ignore": [
"out/client/**/*",
"src/"
],
});
});
gulp.task('watch', () => {
gulp.watch(['src/server/**/*.js', 'src/tests/**/*.js'], ['make-server', 'lint', 'test']);
});
gulp.task('make-server', () => {
gulp.src(['src/server/**/*.js', 'src/shared/**/*.js', 'src/tests/**/*.js'], { base: './src' })
.pipe(babel({
"stage": 1,
"env": {
"development": {
"plugins": ["react-transform"],
"extra": {
"react-transform": {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}]
}
}
}
}
}))
.pipe(gulp.dest('out'));
});
gulp.task('static-assets', () => {
gulp.src(['src/server/index.html', 'src/server/favicon.ico'])
.pipe(gulp.dest('out/server'));
});
gulp.task('lint', () => {
gulp.src(['src/**/*.js', 'test/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
});
gulp.task('prod-webpack', (done) => {
webpack(webpackProdConfig, (err, stats) => {
if (err) throw new PluginError('webpack', err);
util.log('[webpack]', stats.toString());
done();
})
});
gulp.task('clean', () => del(['out/**']));