-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
executable file
·275 lines (254 loc) · 8 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
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
dev: {
options: {
beautify: true,
mangle: false
},
files: {
"html/js/main.js": "build/js/main.js"
},
},
prod: {
options: {
beautify: true,
banner: '/*! last updated <%= grunt.template.today("yyyy-mm-dd") %> */\n',
mangle: {
except:['jQuery'],
}
},
files: {
"html/js/main.js": "build/js/main.js"
},
},
},
htmlmin: { // Task
dev: { // Another target
files: {
'html/index.html': 'build/index.html',
},
},
prod: { // Target
options: { // Target options
removeComments: true,
collapseWhitespace: true
},
files: { // Dictionary of files
'html/index.hml': 'build/index.html',
},
},
},
// image optimazations
imagemin: { // Task
dev: { // Another target
options: { // Target options
optimizationLevel: 1,
pngquant: true
},
files: [{
expand: true, // Enable dynamic expansion
cwd: 'build/img', // Src matches are relative to this path
src: ['**/*.{png,jpg,gif}'], // Actual patterns to match
dest: 'html/img/' // Destination path prefix
}]
}
},
jshint: {
files: ['build/js/*.js'],
options: {
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
}
},
svgmin: { // Task
options: { // Configuration that will be passed directly to SVGO
plugins: [{
removeViewBox: false
}]
},
dev: { // Target
files: [{ // Dictionary of files
expand: true, // Enable dynamic expansion.
cwd: 'build/img', // Src matches are relative to this path.
src: ['**/*.svg'], // Actual pattern(s) to match.
dest: 'html/img/', // 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
}]
}
},
cssmin: {
add_banner: {
options: {
banner: '/* updated <%= grunt.template.today("yyyy-mm-dd") %> */'
},
files: {
'html/stylesheets/screen.css': ['stylesheets/*.css']
}
}
},
compass: { // Task
default: { // Another target
options: {
config: 'config.rb'
}
}
},
validation: {
options: {
reset: grunt.option('reset') || false,
stoponerror: false,
relaxerror: ["Bad value X-UA-Compatible for attribute http-equiv on element meta."]
},
files: {
src: ['html/**/*.html','! node_modules/**/*.html']
}
},
copy: {
main:{
files:[
{
expand: true,
flatten: true,
src: ['build/js/**'],
dest: 'html/js/',
filter:'isFile'},
],
},
},
modernizr: {
dist:{
"dest": "html/js/modernizr.js",
"minify": true,
"options": [
"setClasses"
],
"feature-detects": [
"test/audio",
"test/canvas",
"test/emoji",
"test/fullscreen-api",
"test/geolocation",
"test/hashchange",
"test/input",
"test/json",
"test/notification",
"test/svg",
"test/touchevents",
"test/vibration",
"test/video",
"test/web-intents",
"test/webanimations",
"test/webgl",
"test/a/download",
"test/audio/preload",
"test/battery/lowbattery",
"test/css/animations",
"test/css/appearance",
"test/css/backgroundcliptext",
"test/css/backgroundrepeat",
"test/css/backgroundsize",
"test/css/backgroundsizecover",
"test/css/borderradius",
"test/css/boxshadow",
"test/css/boxsizing",
"test/css/calc",
"test/css/flexbox",
"test/css/gradients",
"test/css/lastchild",
"test/css/mediaqueries",
"test/css/multiplebgs",
"test/css/opacity",
"test/css/pointerevents",
"test/css/rgba",
"test/css/scrollbars",
"test/css/transforms",
"test/css/transitions",
"test/css/userselect",
"test/css/vhunit",
"test/css/vwunit",
"test/elem/time",
"test/event/deviceorientation-motion",
"test/file/api",
"test/file/filesystem",
"test/forms/fileinput",
"test/forms/validation",
"test/img/sizes",
"test/img/srcset",
"test/storage/localstorage",
"test/storage/sessionstorage",
"test/svg/asimg",
"test/svg/clippaths",
"test/svg/filters",
"test/svg/inline",
"test/url/data-uri"
]
}
},
watch: {
options: {
livereload: true,
},
html:{
files: ['html/**/*.html','craft/**/*.html','html/**/*.php'],
tasks: ['build'],
},
js:{
files: ['build/**/*.js'],
tasks: ['jshint','copy'],
},
sass:{
options:{
livereload: false,
},
files: ['build/sass/**/*.scss'],
tasks: ['compass'],
},
img:{
files: ['build/img/**/*.img'],
tasks: ['images'],
},
css:{
files: ['html/stylesheets/**/*.css'],
tasks:[],
}
}
});
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-html-validation');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks("grunt-modernizr");
grunt.loadNpmTasks('grunt-newer');
grunt.registerTask('images', [], function () {
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-svgmin');
grunt.task.run('newer:imagemin','newer:svgmin');
});
// Default tasks
grunt.registerTask('build', ['images','compass','jshint','uglify:dev']);
grunt.registerTask('prod', ['imagemin','svgmin','compass','cssmin','uglify:prod','htmlmin:prod','modernzir:dist']);
// Custom tasks
grunt.registerTask("validate", ['validation']);
grunt.registerTask("img", ['imagemin','svgmin']);
//watchs
grunt.registerTask('watchSetBuild', ['watch:set1','watch:set2']);
// run grunt watch to run build every time a file changes
// grunt.event.on('watch', function(action, filepath) {
// grunt.log.writeln(filepath + ' has ' + action);
// });
};