This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
71 lines (58 loc) · 1.79 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var webpack = require('webpack-stream');
var child = require('child_process');
var server = null;
gulp.task('sass', function() {
return gulp.src('./client/assets/sass/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./public/css/'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: './public'
},
})
})
gulp.task('webpack', function() {
return gulp.src('./public')
.pipe(webpack( require('./webpack.config.js')))
.pipe(gulp.dest('./public/'));
});
gulp.task('develop', ['img','index','sass','webpack','compile:swift','run:server','watch']);
gulp.task('watch', ['browserSync', 'sass'], function() {
gulp.watch('./client/sass/*.scss',['sass']);
gulp.watch('./Sources/**/*.swift', ['compile:swift','run:server']);
gulp.watch('./public/*.js', ['webpack']);
gulp.watch('./client/index.html',['index']);
});
gulp.task('compile:swift', function() {
return child.spawnSync('swift', ['build'], {
cwd: '.'
})
});
gulp.task('index', function() {
return gulp.src('./client/index.html')
.pipe(gulp.dest('public/'))
});
gulp.task('img', function() {
return gulp.src('./client/assets/img/*')
.pipe(gulp.dest('public/img/'))
});
gulp.task('run:server', function() {
if (server)
server.kill();
server = child.spawn('./GameOn', [], {
cwd: './.build/debug'
});
server.stderr.on('data', function(data) {
process.stdout.write(data.toString());
});
});
gulp.task('default', ['img', 'index', 'webpack','sass','compile:swift']);