forked from UPCnet/max.ui.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
242 lines (220 loc) · 7.08 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
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' ]
},
// 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' ]
},
},
// Minify less-compiled css
cssmin: {
dist: {
expand: true,
cwd: 'src/css/',
src: ['maxui.css'],
dest: 'dist/',
ext: '.min.css'
}
},
replace: {
dist: {
src: ['dist/maxui.min.css'],
overwrite: true, // overwrite matched source files
replacements: [{
from: "../font/maxicons",
to: "font/maxicons"
}]
}
},
// 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: {
templates: {
options: {
separator: ",\n\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: '/*jshint multistr: true */\n' +
'var max = max || {};\n\n' +
'/**\n' +
'* @fileoverview Provides hogan compiled templates\n' +
'* ready to render.\n' +
'*/\n\n' +
'max.templates = function() {\n\n' +
' var templates = {\n\n',
footer: '\n\n };\n\n' +
' return templates;\n' +
'};',
},
src: ['src/templates/*.mustache'],
dest: 'src/max.templates.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/sockjs-0.3.min.js',
'libs/json2.js',
'libs/sockjs-0.3.4.js',
'libs/stomp-2.3.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.literals.js',
'src/max.utils.js',
'src/max.client.js',
'src/max.ui.js',
'src/max.loader.js'
],
dest: 'dist/maxui.js',
},
},
// Syntax checker
jshint: {
all: ['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']
}
}
},
// 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/', src: 'font', dest: 'builds/<%= uglify.pkg.version %>/'},
{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', ['concat:dist', 'uglify:dist', 'cssmin:dist', 'replace:dist', 'copy:dist']);
grunt.registerTask('build', ['copy:build']);
grunt.registerTask('templates', ['concat:templates']);
};