forked from andrenanninga/medieval-town
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (73 loc) · 1.96 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
'use strict';
var gulp = require('gulp');
var connect = require('gulp-connect');
var plumber = require('gulp-plumber');
var browserify = require('gulp-browserify');
var ghPages = require('gulp-gh-pages');
var replace = require('gulp-replace');
var runSequence = require('run-sequence');
gulp.task('webserver', function() {
connect.server({
root: 'build',
livereload: true
});
});
gulp.task('scripts', function() {
return gulp.src('./src/js/app.js')
.pipe(plumber())
.pipe(browserify())
.pipe(gulp.dest('./build/js'));
});
gulp.task('html', function() {
return gulp.src('src/html/index.html')
.pipe(plumber())
.pipe(gulp.dest('./build'));
});
gulp.task('css', function() {
return gulp.src('src/css/*.css')
.pipe(plumber())
.pipe(gulp.dest('./build/css'));
});
gulp.task('reload', function() {
return gulp.src('build/*.*')
.pipe(plumber())
.pipe(connect.reload());
});
gulp.task('watch', function() {
gulp.watch('src/**/*.*', ['build']);
});
gulp.task('assets', function() {
return runSequence(
'copy-assets',
'clean-models-mtl',
'clean-models-obj'
);
});
gulp.task('copy-assets', function() {
return gulp.src('assets/**/*.*')
.pipe(plumber())
.pipe(gulp.dest('./build/assets'));
});
gulp.task('clean-models-mtl', function() {
return gulp.src('build/assets/models/*.mtl', { base: './' })
.pipe(replace(/^newmtl ([A-Za-z_]*)\.[0-9]*$/gm, 'newmtl $1'))
.pipe(gulp.dest('./'));
});
gulp.task('clean-models-obj', function() {
return gulp.src('build/assets/models/*.obj', { base: './' })
.pipe(replace(/^usemtl ([A-Za-z_]*)\.[0-9]*$/gm, 'usemtl $1'))
.pipe(gulp.dest('./'));
});
gulp.task('build', function() {
return runSequence(
'html',
'css',
'scripts',
'reload'
);
});
gulp.task('deploy', ['assets', 'build'], function() {
return gulp.src('./build/**/*')
.pipe(ghPages());
});
gulp.task('default', ['assets', 'build', 'webserver', 'watch']);