forked from kyle-ssg/agar.io-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
91 lines (78 loc) · 2.28 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
var gulp = require('gulp');
var babel = require('gulp-babel');
var jshint = require('gulp-jshint');
var nodemon = require('gulp-nodemon');
var uglify = require('gulp-uglify');
var util = require('gulp-util');
var mocha = require('gulp-mocha');
var todo = require('gulp-todo');
var webpack = require('webpack-stream');
var fs = require('fs');
gulp.task('build', ['build-client', 'build-server', 'test']);
gulp.task('test', ['lint'], function () {
gulp.src(['test/**/*.js'])
.pipe(mocha());
});
gulp.task('lint', function () {
return gulp.src(['**/*.js', '!node_modules/**/*.js', '!bin/**/*.js'])
.pipe(jshint({
esnext: true
}))
.pipe(jshint.reporter('default', { verbose: true}))
.pipe(jshint.reporter('fail'));
});
gulp.task('build-client', ['lint', 'move-client'], function () {
return gulp.src(['src/client/js/app.js'])
.pipe(uglify())
.pipe(webpack(require('./webpack.config.js')))
.pipe(babel({
presets: [
['es2015', { 'modules': false }]
]
}))
.pipe(gulp.dest('bin/client/js/'));
});
gulp.task('move-client', function () {
return gulp.src(['src/client/**/*.*', '!client/js/*.js'])
.pipe(gulp.dest('./bin/client/'));
});
gulp.task('build-server', ['lint'], function () {
return gulp.src(['src/server/**/*.*', 'src/server/**/*.js'])
.pipe(babel())
.pipe(gulp.dest('bin/server/'));
});
gulp.task('watch', ['build'], function () {
gulp.watch(['src/client/**/*.*'], ['build-client', 'move-client']);
gulp.watch(['src/server/*.*', 'src/server/**/*.js'], ['build-server']);
gulp.start('run-only');
});
gulp.task('todo', ['lint'], function() {
gulp.src('src/**/*.js')
.pipe(todo())
.pipe(gulp.dest('./'));
});
gulp.task('run', ['build'], function () {
nodemon({
delay: 10,
script: './server/server.js',
cwd: "./bin/",
args: ["config.json"],
ext: 'html js css'
})
.on('restart', function () {
util.log('server restarted!');
});
});
gulp.task('run-only', function () {
nodemon({
delay: 10,
script: './server/server.js',
cwd: "./bin/",
args: ["config.json"],
ext: 'html js css'
})
.on('restart', function () {
util.log('server restarted!');
});
});
gulp.task('default', ['run']);