/
Gruntfile.js
128 lines (125 loc) · 3.13 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Use this file to validate all js and json,
// bundle and minify the game js and css
// Require grunt and it's dependencies listed in package.json
// > run "npm install" then
// > run "grunt" in the game root folder
module.exports = function(grunt) {
var init = {
'pkg': grunt.file.readJSON('package.json'),
'version': {
defaults: {
src: ['client/service-worker.js', 'client/package.json', 'client/manifest.json']
}
},
'cssmin': {
target: {
files: [{
expand: true,
cwd: 'client/css',
src: ['*.css'],
dest: 'client/bundle/css',
ext: '.min.css'
},{
expand: true,
rebaseTo: 'client/css',
cwd: 'client/css/heroes',
src: ['*.css'],
dest: 'client/bundle/css/heroes',
ext: '.min.css'
}]
}
},
'uglify': {
options: {
banner: '// <%= pkg.name %> grunt <%= grunt.template.today("yyyy-mm-dd h:MM:ss TT") %> */'
},
target: {
files: [{
src: 'client/js/*.js',
dest: 'client/bundle/js/game.min.js',
},{
src: 'client/js/*/**.js',
dest: 'client/bundle/js/after.min.js'
}]
}
},
'concat': {
css: {
src: [
'client/bundle/css/*.min.css',
'client/bundle/css/**/*.min.css'
],
dest: 'client/bundle/game.min.css'
},
js: {
src: [
'client/bundle/js/game.min.js',
'client/bundle/js/after.min.js'
],
dest: 'client/bundle/game.min.js'
}
},
'clean': [
'client/bundle/js',
'client/bundle/css'
],
'compress': {
main: {
options: {
mode: 'gzip',
level: 9
},
expand: true,
cwd: 'client/',
src: ['**/*.min.css','**/*.min.js','**/*.json', '!**/node_modules/**'],
dest: 'gzip/'
}
}
};
if (electron) {
init.electron = {
winBuild: {
options: {
asar: true,
overwrite: true,
dir: 'client',
out: 'downloads/windows',
electronVersion: 'latest',
platform: 'win32',
arch: 'ia32'
}
},
macosBuild: {
options: {
asar: true,
overwrite: true,
dir: 'client',
out: 'downloads/mac',
electronVersion: 'latest',
platform: 'darwin',
arch: 'x64'
}
},
linuxBuild: {
options: {
asar: true,
overwrite: true,
dir: 'client',
out: 'downloads/linux',
electronVersion: 'latest',
platform: 'linux',
arch: 'ia32'
}
}
};
}
grunt.initConfig(init);
grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
var tasks = ['version', 'cssmin', 'uglify', 'concat', 'clean', 'compress'];
grunt.registerTask('default', tasks);
};