-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
369 lines (348 loc) · 12.5 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
module.exports = function (grunt) {
'use strict';
// Force use of Unix newlines
grunt.util.linefeed = '\n';
var fs = require('fs');
var path = require('path');
var configBridge = grunt.file.readJSON('./grunt/configBridge.json', {
encoding: 'utf8'
});
Object.keys(configBridge.paths).forEach(function (key) {
configBridge.paths[key].forEach(function (val, i, arr) {
arr[i] = path.join('./docs/assets', val);
});
});
//all blocks
var fileNames = [
["basket_empty.html", "Empty basket"],
["basket_hasItem.html", "Basket with items"],
["bread_crumbs.html", "Bread crumbs"],
["carousel_product_crosswise.html", "Horizontal products carousel"],
["carousel_product_vertical.html", "Vertical products carousel"],
["carousel_slide.html", "Slide show"],
["footer.html", "Footer of site"],
["signin_register.html", "Sign in & register"],
["registration.html", "Registration"],
["header.html", "Header of site"],
["mini_basket.html", "Mini basket"],
["navigation.html", "Site navigation"],
["orderSummary.html", "Summary text"],
["pagination.html", "Pagination"],
["product_filter_checkbox.html", "Product filter checklist"],
["product_filter_removable.html", "Product filter removeable"],
["image_viewer.html", "Image viewer"],
["product-list-item.html", "Product list item"],
["product-list-horizontal.html", "Products list view"],
["product-list-vertical.html", "Products thumbnail view"],
["product-option.html", "Product swatch"],
["promotionalCode.html", "Promotional code"],
["quick_info.html", "Quick info box"],
["search.html", "Product search"],
["store_locator_view1.html", "Store locator view1"],
["store_locator_view2.html", "Store locator view2"],
["store_locator_detail.html", "Store locator detail"],
["product_infos_tab.html", "Product infos tab"]
];
fileNames = fileNames.sort(function (x, y) {
return x[1].localeCompare(y[1]);
});
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' * bootCommerce v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
' * Copyright 2015-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
' */\n',
//jqueryCheck: configBridge.config.jqueryCheck.join('\n'),
//jqueryVersionCheck: configBridge.config.jqueryVersionCheck.join('\n'),
// http server
/*'http-server': {
'dev': {
// the server root directory
root: "./",
port: 8282,
// port: function() { return 8282; }
host: "127.0.0.1",
cache: 100000,
showDir: true,
autoIndex: true,
// server default file extension
ext: "html",
// run in parallel with other tasks
runInBackground: false
}
},*/
// Task configuration.
clean: {
blocks: 'blocks/dist',
pages: 'pages/dist'
},
/*
qunit: {
options: {
inject: 'js/tests/unit/phantom.js'
},
files: 'js/tests/index.html'
},*/
jshint: {
options: {
jshintrc: 'blocks/js/.jshintrc',
force: true
},
blocks: {
src: "blocks/js/*.js"
},
pages: {
src: "pages/js/*.js"
}
},
jscs: {
options: {
config: 'blocks/js/.jscsrc',
force: true
},
blocks: {
src: '<%= jshint.blocks.src %>'
},
pages: {
src: '<%= jshint.pages.src %>'
}
},
uglify: {
options: {
preserveComments: 'some',
banner: '<%= banner %>',
sourceMap: false
},
blocks: {
src: 'blocks/dist/js/<%= pkg.name %>.js',
dest: 'blocks/dist/js/<%= pkg.name %>.min.js'
},
pages: {
expand: true,
cwd: 'pages/js/',
src: ['*.js'],
dest: 'pages/dist/js/',
ext: '.min.js',
extDot: 'first'
}
},
less: {
compileBlock: {
options: {
sourceMap: false
},
files: [
{
expand: true, // Enable dynamic expansion.
cwd: 'blocks/less/', // Src matches are relative to this path.
src: ['**/*.less'], // Actual pattern(s) to match.
dest: 'blocks/dist/css/', // Destination path prefix.
ext: '.css', // Dest filepaths will have this extension.
extDot: 'first' // Extensions in filenames begin after the first dot
},
]
},
compilePage: {
options: {
sourceMap: false,
},
files: [
{
expand: true, // Enable dynamic expansion.
cwd: 'pages/less/', // Src matches are relative to this path.
src: ['**/*.less'], // Actual pattern(s) to match.
dest: 'pages/dist/css/', // Destination path prefix.
ext: '.css', // Dest filepaths will have this extension.
extDot: 'first' // Extensions in filenames begin after the first dot
},
]
}
},
autoprefixer: {
options: {
browsers: configBridge.config.autoprefixerBrowsers
},
blocks: {
options: {
//map: true
},
src: 'blocks/dist/css/**/*.css'
},
pages: {
options: {
//map: true
},
src: 'pages/dist/css/**/*.css'
}
},
csslint: {
options: {
csslintrc: 'blocks/less/.csslintrc'
},
blocks: {
expand: true,
cwd: 'blocks/dist/css/',
src: ['*.css', '!*.min.css', '!bootCommerce.css'],
dest: 'blocks/dist/css/'
},
pages: {
expand: true,
cwd: 'pages/dist/css/',
src: ['*.css', '!*.min.css'],
dest: 'pages/dist/css/'
}
},
usebanner: {
options: {
position: 'top',
banner: '<%= banner %>'
},
src: ['blocks/dist/css/**/*.css', 'pages/dist/css/**/*.css']
},
csscomb: {
options: {
config: 'blocksless/.csscomb.json'
},
blocks: {
expand: true,
cwd: 'blocks/dist/css/',
src: ['*.css', '!*.min.css'],
dest: 'blocks/dist/css/'
},
pages: {
expand: true,
cwd: 'pages/dist/css/',
src: ['*.css', '!*.min.css'],
dest: 'pages/dist/css/'
}
},
cssmin: {
options: {
compatibility: 'ie8',
keepSpecialComments: '*',
advanced: false
},
minifyBlocks: {
src: 'blocks/dist/css/<%= pkg.name %>.css',
dest: 'blocks/dist/css/<%= pkg.name %>.min.css'
}
},
concat: {
option: {},
css: {
src: 'blocks/dist/css/*.css',
dest: 'pages/dist/css/<%= pkg.name %>.css'
},
js: {
src: ['blocks/js/*.js', '!blocks/js/bootCommerceBase.js'],
dest: 'blocks/dist/js/<%= pkg.name %>.js'
},
js_base: {
src: ['blocks/js/bootCommerceBase.js', 'blocks/dist/js/<%= pkg.name %>.js'],
dest: 'blocks/dist/js/<%= pkg.name %>.js'
}
},
processhtml: {
pages: {
options: {
process: true,
data: {
message: 'This is development environment',
list: fileNames //get from blocks folder
}
},
files: [
{
expand: true, // Enable dynamic expansion.
cwd: 'pages/', // Src matches are relative to this path.
src: ['*.html'], // Actual pattern(s) to match.
dest: 'pages/dist/', // Destination path prefix.
ext: '.html', // Dest filepaths will have this extension.
extDot: 'first' // Extensions in filenames begin after the first dot
}
]
},
blocks: {
options: {
process: true
},
files: [
{
expand: true, // Enable dynamic expansion.
cwd: 'blocks/', // Src matches are relative to this path.
src: ['*.html'], // Actual pattern(s) to match.
dest: 'blocks/dist/', // Destination path prefix.
ext: '.html', // Dest filepaths will have this extension.
extDot: 'first' // Extensions in filenames begin after the first dot
}
]
}
},
htmlhintplus: {
//use default rules
//TODO hint includes and blocks html
options: {
htmlhintrc: "blocks/.htmlhintrc",
force: true
},
html: {
src: ['pages/*.html', 'pages/includes/*.html', 'blocks/*.html']
}
},
watch: {
less: {
files: ['blocks/less/**/*.less', 'pages/less/**/*.less'],
tasks: ['dist-css']
},
js: {
files: ['blocks/js/*.js', 'pages/js/*.js'],
tasks: ['dist-js']
},
html: {
files: ['blocks/*.html','pages/*.html', 'pages/includes/**/*.html'],
tasks: ['processhtml:blocks','processhtml:pages']
}
},
browserSync: {
bsFiles: {
src: [
'blocks/dist/**/*.*',
'pages/dist/**/*.*'
]
},
options: {
watchTask: true,
server: {
baseDir: [
"pages/dist",
"./"
]
},
port: 7272,
host: "127.0.0.1",
reloadDelay: 2000,
reloadOnRestart: false,
browser: ["chrome", "firefox"]
}
}
});
// These plugins provide necessary tasks.
require('load-grunt-tasks')(grunt, {
scope: 'devDependencies'
});
require('time-grunt')(grunt);
// JS distribution task.
grunt.registerTask('dist-js', ['jshint:blocks', 'jshint:pages', 'jscs', 'concat:js', 'concat:js_base', 'uglify']);
// CSS distribution task.
grunt.registerTask('less-compile', ['less:compileBlock', 'less:compilePage']);
grunt.registerTask('dist-css', ['less-compile', 'autoprefixer:blocks', 'autoprefixer:pages', 'csscomb:blocks', 'csscomb:pages', 'csslint:blocks', 'csslint:pages', 'cssmin:minifyBlocks', 'usebanner']);
grunt.registerTask('dist-pages', ['htmlhintplus', 'processhtml:blocks', 'processhtml:pages']);
// Full distribution task.
grunt.registerTask('dist', ['clean', 'dist-css', 'dist-pages', 'dist-js']);
// default task
//grunt.registerTask('default', ['clean', 'dist', 'server']);
grunt.registerTask('default', ['clean', 'dist', 'browserSync', 'watch']);
};