-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
88 lines (63 loc) · 1.9 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
// Load modules
var gulp = require('gulp'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
zip = require('gulp-zip'),
htmlreplace = require('gulp-html-replace'),
htmlmin = require('gulp-htmlmin')
;
// optionss and names and stuff
var options = {
js_files : [ 'assets/js/audio.js', 'assets/js/car.js', 'assets/js/player.js', 'assets/js/points.js', 'assets/js/draw.js', 'assets/js/init.js' ],
jsmin : 'roadthegame.js',
css : [ 'assets/css/style.css'],
html : 'index.html',
compile : 'compile',
build : 'build',
archive : 'roadthegame.zip',
archive_content : [ 'compile/*', 'index.html' ]
};
// Create the minified version of all JS files
gulp.task('js', function() {
return gulp.src(options.js_files)
.pipe(concat(options.jsmin))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(options.compile))
;
});
// Create the minified version of all CSS files
gulp.task('css', function() {
return gulp.src(options.css)
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest(options.compile))
;
});
// Replace blocks and minifiy the HTML
gulp.task('html', function() {
return gulp.src(options.html)
// Replace blocks with new code
.pipe(htmlreplace({
'css': 'style.min.css',
'js': 'roadthegame.min.js'
}))
// Minify the HTML
.pipe(htmlmin({
collapseWhitespace: true,
removeComments : true
}))
.pipe(gulp.dest(options.compile))
;
});
// Calls other tasks and creates the archive
gulp.task('build', [ 'js', 'css', 'html' ], function() {
return gulp.src(options.archive_content)
.pipe(zip(options.archive))
.pipe(gulp.dest(options.build))
.pipe(notify({ message: 'created ' + options.archive + '!' }))
;
});