forked from rafaelcastrocouto/foda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
154 lines (150 loc) · 3.8 KB
/
Copy pathGruntfile.js
File metadata and controls
154 lines (150 loc) · 3.8 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// 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
// To create updated electron executables apps
// run "npm install grunt-electron" in the game root folder
// and var election = true below
var electron = false;
module.exports = function(grunt) {
var init = {
'pkg': grunt.file.readJSON('package.json'),
'jshint': {
options: {
esversion: 6,
reporterOutput: "",
laxcomma: true
},
all: [
'package.json',
'Gruntfile.js',
'server.js',
'client/json/**/*.json',
'client/js/**/*.js'
]
},
'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") %> */\n'
},
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/browser_modules/**/*.min.css',
'client/bundle/css/*.min.css',
'client/bundle/css/**/*.min.css'
],
dest: 'client/bundle/game.min.css'
},
js: {
src: [
'client/browser_modules/**/*.min.js',
'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-contrib-jshint');
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 = ['jshint', 'version', 'cssmin', 'uglify', 'concat', 'clean', 'compress'];
if (electron) {
grunt.loadNpmTasks('grunt-electron');
tasks.push('electron');
}
grunt.registerTask('default', tasks);
};