-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgruntfile.js
242 lines (212 loc) · 6.54 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
/*global module:false require*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
files: {
grunt: ['gruntfile.js'],
js: ['js/custom/*.js', 'js/custom/**/*.js'],
css: ['css/custom/*.css', 'css/custom/**/*.css'],
sass: ['css/sass/*.scss', 'css/sass/**/*.scss'],
img: ['img']
},
smushit: {
path: { src: '<%= files.img %>' } // recursively replace minified images
},
concat: {
css: {
src: ['<%= files.css %>'],
dest: 'css/libs/z.styles.concat.css'
},
csslibs: {
src: ['css/libs/*.css', 'css/processed/*.css'],
dest: 'css/libs/z.styles.concat.css'
},
cssmin: {
src: ['css/min/*.css'],
dest: 'css/min/styles.min.css'
},
js: {
src: ['<%= files.js %>'],
dest: 'js/libs/z.scripts.concat.js'
},
jslibs: {
src: ['js/libs/*.js'],
dest: 'js/libs/z.scripts.concat.js'
},
jsmin: {
src: ['js/min/*.js'],
dest: 'js/min/scripts.min.js'
}
},
uglify: {
options: {
sourceMap: function(path) { return path.replace(/.js/,".map"); }
},
dist: {
src: ['js/libs/z.scripts.concat.js'],
dest: 'js/min/scripts.min.js'
}
},
jshint: {
files: ['<%= files.grunt %>', '<%= files.js %>'],
options: {
jquery: true,
smarttabs: true,
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
jQuery: true,
Modernizr: true,
console: true,
undef: true,
unused: false
}
},
cssmin: {
dist: {
src: ['css/libs/z.styles.concat.css'],
dest: 'css/min/styles.min.css'
}
},
csslint: {
styles: {
src: ['<%= files.css %>'],
options: {
// 'import': false,
'ids': false,
'font-sizes': false,
'unqualified-attributes': false,
'floats': false,
'overqualified-elements': false,
'adjoining-classes': false,
'important': false,
'box-sizing': false,
'unique-headings': false,
'qualified-headings': false,
'regex-selectors': false,
'universal-selector': false,
'duplicate-properties': false,
'duplicate-background-images': false,
'box-model': false,
'outline-none': false,
'text-indent': false,
'compatible-vendor-prefixes': false,
'star-property-hack': false,
'display-property-grouping': false,
'underscore-property-hack': false
}
}
},
grunticon: {
options: {
src: 'css/custom/svg',
dest: 'css/min/svg'
}
},
// svgo: {
// optimize: {
// files: 'css/min/svg/*.svg'
// }
// },
/*sass: {
styles: {
files: {
'css/libs/zz.sass.css': ['<%= files.sass %>']
}
}
},*/
compass: {
dist: {
options: {
relativeAssets: true,
sassDir: 'css/sass',
cssDir: 'css/processed'
}
}
},
clean: {
build: {
src: ['css/processed']
}
},
watch: {
files: ['<%= files.grunt %>', '<%= files.js %>', '<%= files.css %>', '<%= files.sass %>'],
tasks: ['default']
}
});
// load plugins installed from npm (see package.json)
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-smushit');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-grunticon');
// grunt.loadNpmTasks('svgo-grunt');
/**
* Default task
*
* Lets break it down.
* lint custom JS in /custom/
* concat custom JS into /libs/
* concat custom and non-minified JS libraries/plugins in /libs/
* minify concatenated JS in /libs/ to /min/
* concat all minified JS in /min/
* Then repeate for CSS.
*
* As a result
* pathing will be maintained by the flat structure
* development code will live in concatenated /libs/scripts.js and /libs/styles.css
* production code will live in minified /min/scripts.min.js and /min/styles.min.css
*/
// grunt.registerTask('default', 'lint concat:js concat:jslibs min concat:jsmin csslint concat:css concat:csslibs cssmin concat:cssmin');
grunt.registerTask('default', [
// process js
'jshint', // lint js
'concat:js', // concat js files in /custom/ to /libs/z.concat.js
'concat:jslibs', // concat js files in /libs/ to /libs/z.concat.js (overwriting the file)
'uglify', // minify /libs/z.concat.js to /min/scripts.min.js
'concat:jsmin', // concat js files in /min/ to /min/scripts.min.js (overwriting the file)
// process css
// 'sass', // process sass files and save to /libs/z.sass.css
'compass', // process sass files and save to /libs/z.sass.css
'csslint', // lint css for errors
'concat:css', // concatenate css files in /custom/ to /libs/z.concat.css
'concat:csslibs', // concatenate css files in /libs/ to /libs/z.concat.css (overwriting the file)
'cssmin', // minify /libs/z.concat.css to /min/styles.min.css
'concat:cssmin' // concatenate css files in /min/ to /min/styles.min.css (overwriting the file)
]);
/**
* Cleanup task
*
* Remove the processed Sass CSS files then run the default task
*/
grunt.registerTask('cleanup', ['clean','default']);
/**
* Minify task
*
* Run the default task then losslessly minify images with Yahoo!'s Smush-It
*/
grunt.registerTask('minify', ['default', 'smushit']);
/**
* Icons task
*
* Build icon fallbacks. Optimize SVG.
*/
grunt.registerTask('icons', ['grunticon']);
};