-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
460 lines (436 loc) · 17.6 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
module.exports = function (grunt) {
// Configure
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// The less task.
less: {
// This is the target's name "production".
// You can run this task like this:
// grunt less:production
production: {
options: {
// Set the option to compress the resulting css.
yuicompress: false,
sourceMap: true,
sourceMapFilename: 'src/css/maxui.css.map',
sourceMapRootpath: "../",
sourceMapURL: 'http://localhost:8081/maxui-dev/src/css/maxui.css.map'
},
files: {
// Create a file called "public/css/site.css" from "less/site.less".
// Note: If the directory public/css does not exist, it will be
// created by the task.
"src/css/maxui.css": "src/less/maxui.less"
}
}
},
watch: {
// This task is for detecting changes on *.less files, and execute less compiler
styles: {
// The path 'less/**/*.less' will expand to match every less file in
// the less directory.
files: ['src/less/*.less', 'src/font/*.less', 'src/less/classes/*.less'],
// The tasks to run
tasks: ['less', 'concat:less']
},
// This task is for detecting changes in compiled .css files, and signal livereload on the browser
livereload: {
options: {
livereload: true
},
files: ['src/css/*.css']
},
templates: {
// Genereate concatenated templates file on changing templats
files: ['src/templates/*.mustache'],
// The tasks to run
tasks: ['concat:templates']
},
templateschat: {
// Genereate concatenated templates file on changing templats
files: [
'src/templates/conversation.mustache',
'src/templates/conversationSettings.mustache',
'src/templates/participant.mustache',
'src/templates/participants.mustache',
'src/templates/postBoxChat.mustache',
'src/templates/predictive.mustache',
'src/templates/filters.mustache',
'src/templates/message.mustache',
'src/templates/mainUIChat.mustache',
],
// The tasks to run
tasks: ['concat:templateschat']
}
},
// Minify less-compiled css
cssmin: {
dist: {
expand: true,
cwd: 'src/css/',
src: ['maxui.css'],
dest: 'dist/',
ext: '.min.css'
}
},
replace: {
// Replaces font location for releases
fontlocation: {
src: ['dist/maxui.min.css'],
overwrite: true, // overwrite matched source files
replacements: [{
from: "../font/maxicons",
to: "font/maxicons"
}]
},
// Puts version number from package into place
version: {
src: ['src/max.ui.js'],
overwrite: true, // overwrite matched source files
replacements: [{
from: /maxui.version = '[.\d]+';/g,
to: "maxui.version = '<%= grunt.file.readJSON('package.json').version %>';"
}]
}
},
// Download Fontello fonts based on local configuration
// A session ID is stored in .fontello-session to be able to
// download fonts afer a session save on the web
fontello: {
dist: {
options: {
config: 'src/font/config.json',
zip: 'tmp',
fonts: 'src/font',
styles: 'src/font',
force: true,
sass: true
}
}
},
concat: {
less: {
options: {
separator: '\n\n/*' +
'\n CSS HACKS for IEx' +
'\n*/\n\n'
},
src: ["src/css/maxui.css", "src/css/hacks.css"],
dest: 'src/css/maxui.css'
},
templates: {
options: {
separator: ",\n",
process: function (src, filepath) {
// Strip .mustache extension
var variable_name = filepath.substr(14, filepath.length - 23);
return " " + variable_name + ": Hogan.compile('\\\n" + src.replace(/\n/g, '\\\n ') + " ')";
},
banner: '/*global Hogan */' +
'/*jshint multistr: true */\n' +
'/**\n' +
'* @fileoverview Provides hogan compiled templates\n' +
'* ready to render.\n' +
'*/\n' +
"'use strict';\n\n" +
'var max = max || {};\n\n' +
'max.templates = function() {\n' +
' var templates = {\n',
footer: '\n };\n' +
' return templates;\n' +
'};\n'
},
src: ['src/templates/activity.mustache',
'src/templates/comment.mustache',
'src/templates/conversation.mustache',
'src/templates/conversationSettings.mustache',
'src/templates/filters.mustache',
'src/templates/mainUI.mustache',
'src/templates/message.mustache',
'src/templates/participant.mustache',
'src/templates/participants.mustache',
'src/templates/postBox.mustache',
'src/templates/predictive.mustache',
],
dest: 'src/max.templates.js'
},
templateschat: {
options: {
separator: ",\n",
process: function (src, filepath) {
// Strip .mustache extension
var variable_name = filepath.substr(14, filepath.length - 23);
return " " + variable_name + ": Hogan.compile('\\\n" + src.replace(/\n/g, '\\\n ') + " ')";
},
banner: '/*global Hogan */' +
'/*jshint multistr: true */\n' +
'/**\n' +
'* @fileoverview Provides hogan compiled templates\n' +
'* ready to render.\n' +
'*/\n' +
"'use strict';\n\n" +
'var max = max || {};\n\n' +
'max.templates = function() {\n' +
' var templates = {\n',
footer: '\n };\n' +
' return templates;\n' +
'};\n'
},
src: [
'src/templates/conversation.mustache',
'src/templates/conversationSettings.mustache',
'src/templates/participant.mustache',
'src/templates/participants.mustache',
'src/templates/postBoxChat.mustache',
'src/templates/predictive.mustache',
'src/templates/filters.mustache',
'src/templates/message.mustache',
'src/templates/mainUIChat.mustache',
],
dest: 'src/max.templateschat.js'
},
templatesactivity: {
options: {
separator: ",\n",
process: function (src, filepath) {
// Strip .mustache extension
var variable_name = filepath.substr(14, filepath.length - 23);
return " " + variable_name + ": Hogan.compile('\\\n" + src.replace(/\n/g, '\\\n ') + " ')";
},
banner: '/*global Hogan */' +
'/*jshint multistr: true */\n' +
'/**\n' +
'* @fileoverview Provides hogan compiled templates\n' +
'* ready to render.\n' +
'*/\n' +
"'use strict';\n\n" +
'var max = max || {};\n\n' +
'max.templates = function() {\n' +
' var templates = {\n',
footer: '\n };\n' +
' return templates;\n' +
'};\n'
},
src: [
'src/templates/activity.mustache',
'src/templates/comment.mustache',
'src/templates/postBox.mustache',
'src/templates/predictive.mustache',
'src/templates/filters.mustache',
'src/templates/message.mustache',
'src/templates/mainUIActivity.mustache',
],
dest: 'src/max.templatesactivity.js'
},
dist: {
options: {
separator: '\n\n;\n\n',
stripBanners: true
},
src: [
'libs/hogan-2.0.0.js',
'libs/jquery.easydate-0.2.4.js',
'libs/jquery.iecors.js',
'libs/jquery.mousewheel-3.1.9.js',
'libs/json2.js',
'libs/stomp.js',
'libs/underscore-1.6.0.js',
'libs/uuid-1.4.1.js',
'libs/ua-parser-1.7.1.js',
'src/max.views.inputs.js',
'src/max.views.overlay.js',
'src/max.views.chatinfo.js',
'src/max.views.scrollbar.js',
'src/max.views.conversations.js',
'src/max.templates.js',
'src/max.messaging.js',
'src/max.logging.js',
'src/max.literals.js',
'src/max.utils.js',
'src/max.client.js',
'src/max.ui.js',
'src/max.loader.js'
],
dest: 'dist/maxui.js'
},
distchat: {
options: {
separator: '\n\n;\n\n',
stripBanners: true
},
src: [
'libs/hogan-2.0.0.js',
'libs/jquery.easydate-0.2.4.js',
'libs/jquery.iecors.js',
'libs/jquery.mousewheel-3.1.9.js',
'libs/json2.js',
'libs/stomp.js',
'libs/underscore-1.6.0.js',
'libs/uuid-1.4.1.js',
'libs/ua-parser-1.7.1.js',
'src/max.views.inputs.js',
'src/max.views.overlay.js',
'src/max.views.scrollbar.js',
'src/max.views.chatinfo.js',
'src/max.views.conversationschat.js',
'src/max.templateschat.js',
'src/max.messaging.js',
'src/max.logging.js',
'src/max.literals.js',
'src/max.utils.js',
'src/max.client.js',
'src/max.uichat.js',
'src/max.loaderchat.js'
],
dest: 'dist/maxuichat.js'
},
distactivity: {
options: {
separator: '\n\n;\n\n',
stripBanners: true
},
src: [
'libs/hogan-2.0.0.js',
'libs/jquery.easydate-0.2.4.js',
'libs/jquery.iecors.js',
'libs/jquery.mousewheel-3.1.9.js',
'libs/json2.js',
'libs/stomp.js',
'libs/underscore-1.6.0.js',
'libs/uuid-1.4.1.js',
'libs/ua-parser-1.7.1.js',
'src/max.views.inputs.js',
'src/max.views.overlay.js',
'src/max.views.scrollbar.js',
'src/max.templatesactivity.js',
'src/max.messaging.js',
'src/max.logging.js',
'src/max.literals.js',
'src/max.utils.js',
'src/max.client.js',
'src/max.uiactivity.js',
'src/max.loaderactivity.js'
],
dest: 'dist/maxuiactivity.js'
}
},
// Syntax checker
jshint: {
options: {
globalstrict: true,
undef: true,
latedef: true,
indent: 4,
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
esversion: 6,
unused: 'vars',
globals: {
"jQuery": true,
"alert": true,
"module": true,
"JSON": true,
"_" :true
}
},
all: ['src/max*.js']
},
jsbeautifier: {
"default": {
src: ["src/max.*.js"],
options: {
js: {
braceStyle: "collapse",
breakChainedMethods: false,
e4x: false,
evalCode: false,
indentChar: " ",
indentLevel: 0,
indentSize: 4,
indentWithTabs: false,
jslintHappy: false,
keepArrayIndentation: true,
keepFunctionIndentation: true,
maxPreserveNewlines: 2,
preserveNewlines: false,
spaceBeforeConditional: true,
spaceInParen: false,
unescapeStrings: false,
wrapLineLength: 0
}
}
}
},
// JS Compressor
uglify: {
pkg: grunt.file.readJSON('package.json'),
dist: {
options: {
sourceMap: true,
banner: '/*! <%= uglify.pkg.name %> - v<%= uglify.pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */'
},
files: {
'dist/maxui.min.js': ['dist/maxui.js'],
'dist/maxuichat.min.js': ['dist/maxuichat.js'],
'dist/maxuiactivity.min.js': ['dist/maxuiactivity.js']
}
}
},
// Copy files plugin
copy: {
dist: {
files: [{
src: 'src/font/maxicons.eot',
dest: 'dist/font/maxicons.eot'
}, {
src: 'src/font/maxicons.svg',
dest: 'dist/font/maxicons.svg'
}, {
src: 'src/font/maxicons.ttf',
dest: 'dist/font/maxicons.ttf'
}, {
src: 'src/font/maxicons.woff',
dest: 'dist/font/maxicons.woff'
}]
},
build: {
files: [{
expand: true,
cwd: 'dist/font',
src: '*',
dest: 'builds/<%= uglify.pkg.version %>/font/'
}, {
expand: true,
cwd: 'dist/',
src: 'maxui*',
dest: 'builds/<%= uglify.pkg.version %>/'
}]
}
},
dalek: {
options: {},
test: {
src: ['test/test.js']
}
}
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-fontello');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-dalek');
grunt.registerTask('dist', ['replace:version', 'concat:dist', 'concat:distchat', 'concat:distactivity', 'uglify:dist', 'cssmin:dist', 'replace:fontlocation', 'copy:dist']);
grunt.registerTask('build', ['copy:build']);
grunt.registerTask('templates', ['concat:templates','concat:templateschat', 'concat:templatesactivity']);
grunt.registerTask('')
};