-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
97 lines (89 loc) · 2.82 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
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
build: ["build/"],
prezip: ["build/game.js", "build/levels.js"]
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
mangle: true
},
build: {
files: {
'build/game.min.js': ['build/levels.js', 'build/game.js']
}
}
},
'string-replace': {
options: {
saveUnchanged: true
},
html: {
options: {
replacements: [{
pattern: /<\!\-\-START\-\->[\S\s]*<\!\-\-END\-\->/ig,
replacement: '<link rel="stylesheet" href="game.min.css" /><script src="game.min.js"></script>'
}, {
pattern: /[\r\n]/ig,
replacement: ''
}, {
pattern: /> +</ig,
replacement: '><'
}]
},
files: {
'build/game.html': ['game.html']
}
},
js: {
options: {
replacements: [{
pattern: /(\/\*\-DEBUG:START\-\*\/)[\S\s]*?(\/\*\-DEBUG:END\-\*\/)/ig,
replacement: ''
}]
},
files: {
'build/': ['*.js', '!Gruntfile.js']
}
},
},
copy: {
build: {
files: {
'build/sprites.png': 'sprites.png',
'build/bg.jpg': 'bg.jpg'
}
}
},
cssmin: {
build: {
files: {
'build/game.min.css': 'game.css'
}
}
},
compress: {
build: {
options: {
archive: 'build.zip',
mode: 'zip',
level: 9
},
expand: true,
cwd: 'build/',
src: ['**/*'],
dest: './'
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.registerTask('default', ['clean:build', 'string-replace:html', 'string-replace:js', 'uglify', 'cssmin', 'copy', 'clean:prezip', 'compress']);
};