-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
123 lines (111 loc) · 3.38 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
var gmWatch = true;
const gulp = require('gulp');
const babel = require('gulp-babel');
const jshint = require('gulp-jshint');
var nodemon = require('gulp-nodemon');
const uglify = require('gulp-uglify');
const util = require('gulp-util');
const mocha = require('gulp-mocha');
// const todo = require('gulp-todo');
const webpack = require('webpack-stream');
const fs = require('fs');
const path = require('path');
const { doesNotMatch } = require('assert');
// gulp.task('build', gulp.series('build_client', 'build_server', 'test', (done) => {}));
function testf(done){
gulp.src([path.resolve(__dirname, "./test/**/*.js")])
.pipe(mocha());
done();
}
function lint(done){
gulp.src(['**/*.js', '!node_modules/**/*.js', '!bin/**/*.js'])
.pipe(jshint({
esnext: true
}))
.pipe(jshint.reporter('default', { verbose: true}))
.pipe(jshint.reporter('fail'));
done();
}
function build_clientf(done){
gulp.src([path.resolve(__dirname, "./src/client/js/app.js")])
.pipe(uglify())
.pipe(webpack(require('./webpack.config.js')))
.pipe(babel())
// .pipe(gulp.dest('bin/client/js/'));
.pipe(gulp.dest(path.resolve(__dirname, "./bin/client/js/")));
done();
}
function move_client(done){
gulp.src([path.resolve(__dirname,'./src/client/**/*.*'), '!client/js/*.js'])
.pipe(gulp.dest(path.resolve(__dirname,'./bin/client/')));
done();
}
function build_serverf(done){
gulp.src(path.resolve(__dirname,'./src/server/lib/*.*'))
.pipe(babel())
.pipe(gulp.dest(path.resolve(__dirname,'./bin/server/lib/')));
gulp.src(path.resolve(__dirname,'./src/server/server.js'))
.pipe(babel())
.pipe(gulp.dest(path.resolve(__dirname,'./bin/server/')));
done();
}
function watchf(done){
gulp.watch(['src/client/**/*.*'], gulp.series('build_client', 'move_client'));
gulp.watch(['src/server/*.*', 'src/server/**/*.js'], gulp.series('build_server'));
gulp.start('run_only');
done();
}
function todof(done){
gulp.src('src/**/*.js')
.pipe(todo())
.pipe(gulp.dest('./'));
done();
}
function runf(done){
nodemon({
delay: 10,
script: 'bin/server/server.js',
// cwd: path.resolve(__dirname, "./bin/"),
args: ["config.json"],
ext: 'html js css',
done: done
})
.on('restart', function () {
util.log('server restarted!');
});
done();
}
function run_only(done){
nodemon({
delay: 10,
script: 'bin/server/server.js',
// cwd: path.resolve(__dirname, "./bin/"),
args: ["config.json"],
ext: 'html js css'
})
.on('restart', function () {
util.log('server restarted!');
});
done();
}
function buildf(done){
done();
}
// define complex tasks
const test = gulp.series(testf, gulp.parallel(lint));
const build_client = gulp.series(build_clientf, gulp.parallel(lint,move_client));
const build_server = gulp.series(build_serverf, gulp.parallel(lint));
// const build = gulp.parallel(build_client, build_server, test);
const build = gulp.series(buildf, gulp.parallel(build_client, build_server, test));
const watch = gulp.series(watchf, gulp.parallel(build));
const todo = gulp.series(todof, gulp.parallel(lint));
const run = gulp.series(runf, gulp.parallel(build));
// export tasks
exports.build = build;
exports.test = test;
exports.build_client = build_client;
exports.build_server = build_server;
exports.watch = watch;
exports.todo = todo;
exports.run = run;
exports.default = run;