-
Notifications
You must be signed in to change notification settings - Fork 130
/
gulpfile.js
77 lines (66 loc) · 2.24 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
66
67
68
69
70
71
72
73
74
75
76
77
var gulp = require("gulp");
var babel = require('gulp-babel');
var browserify = require("browserify");
var babelify = require("babelify");
var reactify = require("reactify");
var source = require("vinyl-source-stream");
var nodemon = require("gulp-nodemon");
var eslint = require('gulp-eslint');
var clean = require('gulp-clean');
gulp.task("lint", [], function () {
return gulp.src(['src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task("bundle-client", ["lint"], function () {
return browserify({
entries: "./src/client/main.js",
debug: true
}).transform(babelify, { presets: ["@babel/preset-env", "@babel/preset-react"] })
.transform(reactify)
.bundle()
.pipe(source("main.js"))
.pipe(gulp.dest("dist/client"));
});
gulp.task('clean', function () {
return gulp.src('dist', { read: false })
.pipe(clean());
});
gulp.task("deploy-client", ["bundle-client"], function () {
return gulp.src(["src/client/index.html", "src/client/lib/bootstrap-css/css/bootstrap.min.css", "src/client/style.css", "src/client/assets/background.jpg"])
.pipe(gulp.dest("dist/client"));
});
gulp.task('deploy-server-config', [], function () {
return gulp.src(["src/config/config.json", "src/config/users.json", "src/config/strategies.json"])
.pipe(gulp.dest("dist/config"));
});
gulp.task('deploy-server', ["lint", "deploy-server-config"], function () {
return gulp.src('src/server/**/*.js')
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(gulp.dest('dist/server'));
});
gulp.task('deploy', ["deploy-client", "deploy-server"], function () {
console.log('Deployed client and server..');
});
gulp.task('watch', [], function () {
return gulp.watch(['src/server/**/*.js'], function (event) {
console.info('File changed: ', event.path);
gulp.run('deploy-server');
});
});
gulp.task("server", ["watch"], function () {
var stream = nodemon({
script: 'dist/server/index.js',
ext: 'html js jsx css',
ignore: ['src', 'dist/client']
});
stream.on('restart', function () {
console.log('restarted!');
}).on('crash', function () {
console.error('Application has crashed!\n');
stream.emit('restart', 10); // restart the server in 10 seconds
});
});