-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
362 lines (316 loc) · 7.37 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
module.exports = function (grunt) {
'use strict';
/**
* Project configuration
*/
grunt.initConfig({
pkg: require('./package'), // <%=pkg.name%>
/**
* Config - Edit this section
* ==========================
* Choose javascript dist filename
* Choose javascript dist location
* Choose javascript files to be uglified
*/
config : {
js : {
// <%=config.js.distDir%>
distDir : 'js/dist/',
// <%=config.js.distFile%>
distFile : 'app.min.js',
// <%=config.js.fileList%>
fileList : [
'js/helpers/console.js',
'js/script.js'
]
}
},
/**
* Watch
* https://github.com/gruntjs/grunt-contrib-watch
* Watches your scss, js etc for changes and compiles them
*/
watch: {
scss: {
files: ['scss/**/*.scss'],
tasks: ['sass:kickoff', 'sass:styleguide', 'autoprefixer:dist']
},
js: {
files: ['<%=config.js.fileList%>', 'Gruntfile.js'],
tasks: ['uglify']
},
livereload: {
options: { livereload: true },
files: [
'css/*.css'
]
},
grunticon : {
files: ['img/src/*.svg', 'img/src/*.png'],
tasks: ['svgmin', 'grunticon']
}
},
/**
* Sass compilation
* https://github.com/gruntjs/grunt-contrib-sass
* Includes kickoff.scss and kickoff-old-ie.scss by default
* Also creates source maps
*/
sass: {
kickoff: {
options: {
unixNewlines: true,
style: 'expanded',
lineNumbers: false,
debugInfo : false,
precision : 8,
sourcemap: true,
loadPath: 'scss'
},
files: {
'css/kickoff.css' : 'scss/kickoff.scss',
'css/kickoff-old-ie.css': 'scss/kickoff-old-ie.scss'
}
},
styleguide: {
options: {
unixNewlines: true,
style: 'expanded',
precision : 8,
sourcemap: true,
loadPath: 'scss'
},
files: {
'css/styleguide.css': 'scss/styleguide.scss'
}
}
},
/**
* Autoprefixer
* https://github.com/nDmitry/grunt-autoprefixer
* https://github.com/ai/autoprefixer
* Auto prefixes your CSS using caniuse data
*/
autoprefixer: {
dist : {
options: {
// Task-specific options go here - we are supporting
// the last 2 browsers, any browsers with >1% market share,
// and ensuring we support IE7 + 8 with prefixes
browsers: ['> 5%', 'last 4 versions', 'firefox > 3.6', 'ie > 6'],
map: true
},
files: {
'css/kickoff.css' : 'css/kickoff.css',
'css/kickoff-old-ie.css': 'css/kickoff-old-ie.css',
'css/styleguide.css' : 'css/styleguide.css'
}
}
},
/**
* Uglify
* https://github.com/gruntjs/grunt-contrib-uglify
* Minifies and concatinates your JS
* Also creates source maps
*/
uglify: {
options: {
mangle: true, // mangle: Turn on or off mangling
beautify: false, // beautify: beautify your code for debugging/troubleshooting purposes
compress: false,
// report: 'gzip', // report: Show file size report
sourceMap: '<%=config.js.distDir%><%=config.js.distFile%>.map',
sourceMappingURL: '/<%=config.js.distFile%>.map',
},
js: {
src: '<%=config.js.fileList%>',
dest: '<%=config.js.distDir%><%=config.js.distFile%>'
}
},
/**
* Grunticon
* https://github.com/filamentgroup/grunticon
*/
grunticon: {
myIcons: {
files: [{
expand: true,
cwd : 'img/src-min',
src : ['*.svg', '*.png'],
dest : 'img/icons'
}],
options: {
customselectors: {
"team": [".teamList:before"]
}
}
}
},
/**
* SVGmin
* https://github.com/sindresorhus/grunt-svgmin
*/
svgmin: {
options: {
plugins: [
{ removeViewBox: false },
{ removeUselessStrokeAndFill: false }
]
},
dist: { // Target
files: [{ // Dictionary of files
expand: true, // Enable dynamic expansion.
cwd: 'img/src', // Src matches are relative to this path.
src: ['**/*.svg'], // Actual pattern(s) to match.
dest: 'img/src-min', // Destination path prefix.
ext: '.svg' // Dest filepaths will have this extension.
// ie: optimise img/src/branding/logo.svg and store it in img/branding/logo.min.svg
}]
}
},
/**
* CSSO
* https://github.com/t32k/grunt-csso
* Minify CSS files with CSSO
*/
csso: {
dist: {
files: {
'css/kickoff.css' : 'css/kickoff.css',
'css/kickoff-old-ie.css': 'css/kickoff-old-ie.css'
},
}
},
/**
* Connect
* https://github.com/gruntjs/grunt-contrib-connect
* Start a static web server
*/
connect: {
server: {
options: {
// port: 9001,
// hostname: 'mysite.local',
open: true,
livereload: true,
base: './_site'
}
}
},
/**
* Custom jQuery builder
* Check build numbers at jquery.com
*/
jquery: {
build: {
options: {
prefix: "jquery-",
minify: true
},
output: "js/libs/jquery",
versions: {
// Add items to the below arrays to remove them from the build
// Remove everything we don't need from 2.x versions
//"2.0.3": [ "deprecated", "dimensions", "offset", "wrap"],
// We can't remove sizzle from 1.x versions, so let's not specify it
"1.10.2": [ "deprecated"]
}
}
},
/**
* JSHint
* https://github.com/gruntjs/grunt-contrib-jshint
* Manage the options inside .jshintrc file
*/
jshint: {
all: '<%=config.js.fileList%>',
options: {
jshintrc: '.jshintrc'
}
},
/**
* JSCS
* https://github.com/dsheiko/grunt-jscs
* Manage the options inside .jscs.json file
*/
jscs: {
src: '<%=config.js.fileList%>',
options: {
config: ".jscs.json"
}
}
});
// Load all the grunt tasks
require('load-grunt-tasks')(grunt);
/* ==========================================================================
Available tasks:
* grunt : run jshint, uglify and sass:kickoff
* grunt watch : run sass:kickoff, uglify and livereload
* grunt dev : run jshint, uglify and sass:kickoff
* grunt deploy : run jshint, uglify, sass:kickoff and csso
* grunt jquery : build custom version of jquery
* grunt serve : watch js & scss and run a local server
========================================================================== */
/**
* GRUNT * Default task
* run jshint, uglify and sass:kickoff
*/
// Default task
grunt.registerTask('default', [
'jshint',
'uglify',
'sass:kickoff',
'autoprefixer:dist'
]);
/**
* GRUNT DEV * A task for development
* run jshint, uglify and sass:kickoff
*/
grunt.registerTask('dev', [
'uglify',
'sass:kickoff',
'autoprefixer:dist',
'svgmin',
'grunticon'
]);
/**
* GRUNT DEPLOY * A task for your production environment
* run jshint, uglify and sass:production
*/
grunt.registerTask('deploy', [
'uglify',
'sass:kickoff',
'autoprefixer:dist',
'csso'
]);
/**
* GRUNT SERVE * A task for for a static server with a watch
* run connect and watch
*/
grunt.registerTask("serve", [
'dev',
'connect',
'watch'
]);
/**
* GRUNT SERVE * A task for for a static server with a watch
* run connect and watch
*/
grunt.registerTask("drafts", [
'dev',
'connect',
'watch'
]);
/**
* TODO:
* Need task to update all grunt dependencies
* Need task to download all bower dependencies
*/
//Travis CI to test build
grunt.registerTask('travis', [
'jshint',
'uglify',
'sass:kickoff',
'autoprefixer:dist'
]);
};