-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathgulpfile.js
62 lines (53 loc) · 1.71 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
var gulp = require('gulp'),
concat = require('gulp-concat'),
zip = require('gulp-zip'),
cssmin = require('gulp-cssmin'),
htmlmin = require('gulp-htmlmin'),
rimraf = require('gulp-rimraf'),
size = require('gulp-size'),
minifier = require('gulp-uglify/minifier'),
webserver = require('gulp-webserver');
gulp.task('default', ['build']);
gulp.task('build', ['build_source','build_index', 'build_styles','compress','webserver']);
gulp.task('build_source',['clean'], () => {
return gulp.src(['src/utils.js','src/sound.js','src/scoreBoard.js','src/glitch.js','src/maze.js','src/player.js','src/game.js','src/ui.js',])
.pipe(concat('game.min.js'))
.pipe(gulp.dest('build'))
})
gulp.task('build_index', function() {
return gulp.src('src/index.html')
.pipe(htmlmin({
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true}))
.pipe(gulp.dest('build'));
});
gulp.task('build_styles', function() {
return gulp.src('src/main.css')
.pipe(cssmin())
.pipe(gulp.dest('build'));
});
gulp.task('compress',['build_source'], function() {
return gulp.src('build/*.*')
.pipe(zip('archive.zip'))
.pipe(size())
.pipe(gulp.dest('build'))
});
gulp.task('clean', function () {
return gulp.src('build/*.*', {read: false})
.pipe(rimraf());
});
/*Needed as cookies used in scoreboard cannot be saved from a file:// address */
gulp.task('webserver', function() {
gulp.src('build')
.pipe(webserver({
livereload: true,
directoryListing: false,
open: true
}));
});
gulp.task('watch', function() {
gulp.watch('src/*.js', ['build_source']);
gulp.watch('src/main.css', ['build_styles']);
gulp.watch('src/index.html', ['build_index']);
});