This repository has been archived by the owner on Jul 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
160 lines (143 loc) · 3.21 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
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
155
156
157
158
159
160
'use strict';
// Use:
//
// grunt build to package javascript code
//
// grunt clean to clean intermediate files
// grunt clean:all to clean all intermediate files
// including android / ios binaries
//
//
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
paths: {
res: 'res',
src: 'base-src',
runtimesrc: 'frameworks/runtime-src',
dist: 'src',
webhome: '.',
test: 'test'
},
properties: grunt.file.isFile('grunt.local.json') ?
grunt.file.readJSON('grunt.local.json') : {},
clean: {
dist: [
'<%= paths.dist %>/bundle-scripts.js',
],
all: [
// cocos has an ugly habit of copying everything to the Android project
'<%= paths.runtimesrc %>/proj.android/assets/**',
'<%= paths.runtimesrc %>/proj.android/bin/**',
'<%= paths.runtimesrc %>/proj.android/libs/**',
'<%= paths.runtimesrc %>/proj.android/obj/**',
'<%= paths.runtimesrc %>/proj.android/gen/**'
]
},
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: './jshint-reporter.js'
},
all: [
'Gruntfile.js',
'<%= paths.src %>/{,*/}*.js',
'<%= paths.res %>/{,*/}*.js',
'<%= paths.webhome %>/*.js',
'<%= paths.test %>/spec/{,*/}*.js',
'!<%= paths.src %>/external/{,*/}*.js'
]
},
mocha: {
all: {
options: {
reporter: 'Spec',
run: false,
urls: ['http://localhost:<%= connect.test.options.port %>/index.html']
}
}
},
watch: {
options: {
livereload: true
},
js: {
files: '<%= jshint.all %>',
tasks: ['jshint', 'browserify']
},
jstest: {
files: '<%= paths.test %>/spec/{,*/}*.js',
tasks: ['test:watch']
}
},
browserify: {
dist: {
files: {
'<%= paths.dist %>/bundled-scripts.js': [
'<%= paths.src %>/boot.js'
]
},
},
options: {
browserifyOptions: {
debug: true
},
external: [
'jsb.js'
]
}
},
compress: {
main: {
options: {
archive: 'archived-web-version.zip'
},
files: [
{
expand: true,
cwd: '.',
src: [
'<%= paths.dist %>/**',
'<%= paths.res %>/**',
'frameworks/cocos2d-html5/**',
'index.html',
'main.js',
'project.json',
]
}
]
}
},
shell: {
},
connect: {
options: {
port: 9000,
open: true,
livereload: true
},
server: {
base: [
'<%= paths.dist %>',
'<%= paths.webhome %>'
]
}
}
});
grunt.registerTask('build', [
'jshint',
'clean:dist',
'browserify'
]);
grunt.registerTask('test', [
'jshint',
'clean:dist',
'mocha'
]);
grunt.registerTask('server', [
'build',
'connect:server',
'watch'
]);
};