forked from brooklyndevs/metroly-html5
/
Gruntfile.js
323 lines (268 loc) · 8.39 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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
module.exports = function(grunt) {
"use strict";
//http://chrisawren.com/posts/Advanced-Grunt-tooling
grunt.initConfig({
globalConfig: {
OUTSIDE_DISTRIBUTION_FOLDER: '../metroly-dist',
LEAFLET_FOLDER: 'assets/libs/leaflet-0.6.4/',
LEAFLET_CLUSTER: 'assets/libs/leaflet-markerCluster/'
},
pkg: grunt.file.readJSON('package.json'),
notify: {
jshint: {
options: {
title: "JSHint linting", message: "Done."
}
},
cssmin: {
options: {
title: "CSS Minification", message: "Done."
}
},
release: {
options: {
title: "Release", message: "Done."
}
}
},
// Watches files for changes
watch: {
scripts: {
files: ['*.js', 'js/**/*.js'],
tasks: ['jshint'],
options: {
message: 'JS files are lint-free',
livereload: true
}
},
design: {
files: ["assets/**.css", "assets/images/**"],
options: {
message: 'CSS files changed...',
livereload: true
}
},
jade: {
files: ['assets/templates/**'],
options: {
message: 'Templates were changed...',
livereload: true
}
},
jasmine: {
files: ['test/spec/jasmine/**'],
tasks: ['jshint', 'karma']
}
},
// Wipe out previous builds and test reporting.
clean: {
release: ["dist/", "test/reports"],
outside: ["<%= globalConfig.OUTSIDE_DISTRIBUTION_FOLDER %>"]
},
// Run your source code through JSHint's defaults.
jshint: ["js/**/*.js"],
// This task uses James Burke's excellent r.js AMD builder to take all
// modules and concatenate them into a single file.
requirejs: {
options: {
// Calls require()/config() calls from main.js file
mainConfigFile: "js/config.js",
include: ["main"],
insertRequire: ["main"],
out: "dist/js/main.js",
// Since we bootstrap with nested `require` calls this option allows
// R.js to find them.
findNestedDependencies: true,
// Include a minimal AMD implementation shim (in shim files).
name: "../node_modules/almond/almond",
// Setting the base url to the distribution directory allows the
// Uglify minification process to correctly map paths for Source
// Maps.
baseUrl: "js",
// Wrap everything in an IIFE.
wrap: true,
// Do not preserve any license comments when working with source
// maps. These options are incompatible.
preserveLicenseComments: false,
// Remove combined files from the dist folder
removeCombined: true,
},
release: {
optimize: "uglify",
generateSourceMaps: false,
},
develop: {
optimize: "uglify2",
generateSourceMaps: true,
}
},
// This task simplifies working with CSS inside Backbone Boilerplate
// projects. Instead of manually specifying your stylesheets inside the
// HTML, you can use `@imports` and this task will concatenate only those paths.
/*
styles: {
// Out the concatenated contents of the following styles into the below
// development file path.
"dist/assets/css/style.css": {
// Point this to where your `index.css` file is location.
src: "dist/assets/css/style.css",
// The relative path to use for the @imports.
paths: ["assets/css"],
// Rewrite image paths during release to be relative to the `img` directory.
forceRelative: "/assets/images/"
}
},*/
// Minify the distribution CSS.
cssmin: {
release: {
options: {
banner: '/* Metroly CSS */'
},
files: { // Add Leaflet to style (make sure it's before script!)
"dist/assets/css/style.css": [
"<%= globalConfig.LEAFLET_FOLDER %>leaflet.css",
"<%= globalConfig.LEAFLET_CLUSTER %>MarkerCluster.*",
"assets/css/*.css"
]
}
}
},
server: {
options: {
host: "0.0.0.0",
port: 8000
},
development: {
},
release: {
options: {
prefix: "dist"
}
},
test: {
options: {
forever: false,
port: 8001
}
}
},
processhtml: {
release: {
files: {
"dist/index.html": ["index.html"]
}
}
},
// Move vendor and app logic during a build.
copy: {
release: {
files: [
// Meetroly icon ftw!
{
src: ["favicon.ico"], dest: "dist/"
},
// Vendor files, Exclude CSS files (cssmin will get them), exclude Old Images
{ src: [
"assets/**",
"!**assets/css/**",
"!**<%= globalConfig.LEAFLET_FOLDER %>leaflet.css",
"!**assets/images/icon_set/old/**"
],
dest: "dist/"
}
]
},
outside: {
files: [ {
src: "dist/*",
dest: "<%= OUTSIDE_DISTRIBUTION_FOLDER %>"
}]
}
},
compress: {
release: {
options: {
mode: 'gzip' // also 'zip','gz'
//archive: "dist/js/main.js.gz"
},
files: [
{
expand: true,
src: ["dist/js/main.js", "dist/assets/libs/require.min.js"],
ext: ".js.gz"
}
]
}
},
// Unit testing is provided by Karma.
karma: {
unit: {
configFile: 'karma.conf.js'
}
},
coveralls: {
options: {
coverage_dir: "test/coverage/PhantomJS 1.9.2 (Linux)/"
}
},
strip : {
main : {
// Remove comments from all js files in dist
src : 'dist/**/*.js',
options : {
inline : true
}
}
},
});
// Grunt contribution tasks.
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-compress");
//grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks("grunt-contrib-watch");
// Third-party tasks. Karma = Testacular
grunt.loadNpmTasks("grunt-karma");
grunt.loadNpmTasks("grunt-karma-coveralls");
grunt.loadNpmTasks("grunt-processhtml");
grunt.loadNpmTasks('grunt-strip');
// Automatic notifications when tasks fail.
grunt.loadNpmTasks('grunt-notify');
// This is required if you use any options.
//grunt.task.run('notify_hooks');
// Grunt BBB tasks.
grunt.loadNpmTasks("grunt-bbb-server");
grunt.loadNpmTasks("grunt-bbb-requirejs");
grunt.loadNpmTasks("grunt-bbb-styles");
// When running the default Grunt command, just lint the code.
grunt.registerTask("default", [
"jshint",
"notify:jshint"
]);
grunt.registerTask("release", [
"jshint", // Test JavaScript for errors
"notify:jshint",
"clean:release", // Clean old Dist folder
"copy:release", // Copy files to Dist folder
"cssmin", // Unite & Minify CSS file (style.css)
"notify:cssmin",
"requirejs:release",// Minify JS files using R.js & Require.js & add AMD definition through Almond
"strip", // Removes console.log, debug statements and such
"processhtml", // Process HTML - build scripts (ex. combines all references into one), images
"clean:outside",
"copy:outside",
"notify:release"
//"compress" // gzip js, css - Should be done by Node
//"server:release" // Run release server
// "karma:run" // Single run of karma testing suite
]);
grunt.registerTask("test-release", [
"clean:release",
"copy:release",
"cssmin", "notify:cssmin",
"requirejs:release",
"processhtml", "notify:release",
]);
};