forked from aydinugur/life-and-death
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
73 lines (65 loc) · 2.18 KB
/
gruntfile.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
// const fs = require("fs");
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compress: {
main: {
options: {
archive: 'dist/game.zip',
mode: 'zip',
level: 9
},
files: [{
expand: true,
flatten: false,
cwd: './dist',
src: ['index.html', 'images/*'],
dest: './'
}]
}
},
processhtml: {
dist: {
options: {
process: true,
data: {
title: 'A Day In The Life',
}
},
files: {
'dist/index.html': ['src/index.html']
}
}
},
copy: {
main: {
files: [
{expand: true, flatten: true, src: ['src/images/*'], dest: 'dist/images'},
{expand: true, flatten: true, src: ['src/index.html'], dest: 'dist'},
],
},
},
clean: ['dist']
});
var fs = require('fs');
grunt.registerTask('sizecheck', function () {
var done = this.async();
fs.stat('dist/game.zip', function (err, zip) {
if (zip.size > 13312) {
//If size in bytes greater than 13kb
grunt.log.error("Zipped file greater than 13kb \x07 \n");
grunt.log.error("WARNING! FILESIZE IS TOO BIG!");
grunt.log.error("Zip is " + zip.size + " bytes when js13k max is 13,312 bytes");
} else {
grunt.log.error("Zip is " + zip.size + " bytes!");
grunt.log.error("Filesize OK!");
}
done();
});
});
grunt.loadNpmTasks('grunt-processhtml');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('default', ['copy', 'compress', 'processhtml', 'sizecheck']);
};