-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
254 lines (206 loc) · 5.37 KB
/
Gruntfile.js
File metadata and controls
254 lines (206 loc) · 5.37 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
module.exports = function(grunt) {
'use strict';
// ============================================
// Grunt Configuration
// ============================================
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// --------------------------------------------
// Benchmark
// --------------------------------------------
benchmark: {
app: {
src: [
'app/scripts/*.js',
'app/benchmarks/*.js'
],
dest: 'app/benchmarks/results.csv',
options: {
displayResults: true
}
},
dist: {
src: [
// 'dist/scripts/sorting-algorithms.min.js',
'dist/benchmarks/*.js'
],
dest: 'dist/benchmarks/results.csv',
options: {
displayResults: true
}
}
},
// --------------------------------------------
// Clean
// --------------------------------------------
clean: {
build: 'build',
distpre: ['dist'],
distpost: [
'dest'
],
server: '.tmp'
},
// --------------------------------------------
// Concatenate Files
// --------------------------------------------
concat: {
core: {
src: [
'app/scripts/*.js'
],
dest: 'dist/scripts/sorting-algorithms.src.js'
}
},
// --------------------------------------------
// Copy Files
// --------------------------------------------
copy: {
dist: {
files: [
{
expand: true,
cwd: 'app',
src: [
'benchmarks/*',
'libraries/**',
'tests/*',
'*.html'
],
dest: 'dist/',
filter: 'isFile'
}
]
}
},
// --------------------------------------------
// Express: Local Node.js Test Server
// --------------------------------------------
express: {
app: {
options: {
port: 9998,
hostname: '0.0.0.0',
bases: ['app/.']
}
},
dist: {
options: {
port: 9999,
hostname: '0.0.0.0',
bases: ['dist/.']
}
}
},
// --------------------------------------------
// JSHint: JavaScript Code Hinting
// --------------------------------------------
jshint: {
files: [
'Gruntfile.js',
'app/scripts/*.js'
],
options: {
// options here to override JSHint defaults
undef: false,
globals: {
// jQuery: true,
// console: true,
// module: true,
// document: true
}
}
},
// --------------------------------------------
// Open
// --------------------------------------------
open: {
app: {
url: 'http://localhost:<%= express.app.options.port %>/jasmine-tests.html'
},
dist: {
url: 'http://localhost:<%= express.dist.options.port %>/jasmine-tests.html'
}
},
// --------------------------------------------
// Uglify: JS Minification
// --------------------------------------------
uglify: {
src: {
options: {
report: 'gzip',
mangle: false
},
src: ['dist/scripts/sorting-algorithms.src.js'],
dest: 'dist/scripts/sorting-algorithms.min.js'
}
},
// --------------------------------------------
// UseMin: Production HTML File Prep
// --------------------------------------------
usemin: {
html: [
'dist/benchmarks.html',
'dist/jasmine-tests.html'
]
}
});
// ============================================
// Load Node Modules
// ============================================
grunt.loadNpmTasks('grunt-benchmark');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-express');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-usemin');
// ============================================
// Grunt Task Creation
// ============================================
grunt.registerTask('server', [
'app-server',
'dist-server',
'express-keepalive'
]);
// for running a painless local server
grunt.registerTask('app-server', [
'clean:server',
'express:app',
'open:app'
]);
// for running a painless local server
grunt.registerTask('dist-server', [
'clean:server',
'express:dist',
'open:dist'
]);
// benchmark.js
grunt.registerTask('compare', [
'benchmark:app',
'benchmark:dist'
]);
// Create the production distribution version
grunt.registerTask('dist', [
// Clear the dist folder
'clean:distpre',
// Check to make sure js code is valid
'jshint',
// Combine the JS files common to both web and digital signage versions
'concat',
// Minify the temp web js code
'uglify',
// Copy over all of the unchanged files to dist
'copy:dist',
// Replace the individual JS links with one link in the HTML files
'usemin',
// Clean up all of the
'clean:distpost'
]);
grunt.registerTask('default', [
'dist'
]);
};