-
Notifications
You must be signed in to change notification settings - Fork 1
/
gruntfile.js
345 lines (299 loc) · 7.68 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
module.exports = function(grunt) {
// To support SASS/SCSS or Stylus, just install
// the appropriate grunt package and it will be automatically included
// in the build process, Sass is included by default:
//
// * for SASS/SCSS support, run `npm install --save-dev grunt-contrib-sass`
// * for Stylus/Nib support, `npm install --save-dev grunt-contrib-stylus`
var npmDependencies = require('./package.json').devDependencies;
var hasSass = npmDependencies['grunt-sass'] !== undefined;
var environment = "james";
if (environment == "james") {
grunt.initConfig({
path: {
assets: 'assets',
src: 'src',
dist: 'dist',
sass: '<%= path.assets %>/css',
js: '<%= path.assets %>/js',
images: '<%= path.assets %>/images',
fonts: '<%= path.assets %>/fonts',
},
// Watches for changes and runs tasks
watch : {
sass : {
files : ['<%= path.sass %>/*.scss', '<%= path.sass %>/**/*.scss'],
tasks : (hasSass) ? ['sass:dev', 'autoprefixer'] : null,
options : {
livereload : true,
sourceMap : true
}
},
js : {
files : ['assets/js/**/*.js'],
tasks : ['jshint', 'uglicat'],
options : {
livereload : true
}
},
php : {
files : ['**/*.php'],
options : {
livereload : true
}
}
},
// JsHint your javascript
jshint : {
all : ['js/*.js', '!js/modernizr.js', '!js/*.min.js', '!js/vendor/**/*.js'],
options : {
browser: true,
curly: false,
eqeqeq: false,
eqnull: true,
expr: true,
immed: true,
newcap: true,
noarg: true,
smarttabs: true,
sub: true,
undef: false
}
},
// Dev and production build for sass
sass : {
production : {
files : [
{
src : ['**/*.scss', '!**/_*.scss'],
cwd : 'assets/css',
dest : 'dist/css',
ext : '.css',
expand : true
}
],
options : {
style : 'compressed'
}
},
dev : {
files : [
{
src : ['**/*.scss', '!**/_*.scss'],
cwd : 'assets/css',
dest : 'dist/css',
ext : '.css',
expand : true
}
],
options : {
style : 'expanded'
}
}
},
// Image min
imagemin : {
production : {
files : [
{
expand: true,
cwd: 'assets/images',
src: '**/*.{png,jpg,jpeg}',
dest: 'dist/images'
}
]
}
},
// SVG min
svgmin: {
options: {
plugins: [{
removeViewBox: false,
collapseGroups: false
}, {
removeUnknownsAndDefaults: false
}]
},
dist: {
files: [{
expand: true,
cwd: '<%= path.images %>',
src: ['*.svg'],
dest: '<%= path.dist %>/images',
ext: '.svg'
}]
}
},
grunticon: {
icons: {
files: [{
expand: true,
cwd: '<%= path.images %>',
src : ['*.svg'],
dest: '<%= path.dist %>/images'
}],
options: {
cssprefix: '.icon--'
}
}
},
// Minify JS
uglify: {
js: {
files: [
{
expand:true,
cwd: 'assets/js',
src: ['**/*.js'],
dest: 'dist/js'
}]
}
},
// Concat JS
concat: {
dist: {
src: ['dist/js/*.js', '!dist/js/global.js'],
dest: 'dist/js/scripts.js',
}
},
// Autoprefixer
autoprefixer: {
single_file: {
flatten : true,
src: 'dist/css/style.css',
dest: 'dist/css/style.css'
}
},
cssmin: {
options: {
shorthandCompacting: false,
roundingPrecision: -1
},
target: {
files: {
'dist/css/style.css': ['dist/css/style.css']
}
}
},
// Modernizr build
modernizr: {
dist: {
// [REQUIRED] Path to the build you're using for development.
"devFile" : "bower_components/modernizr/modernizr.js",
// Path to save out the built file.
"outputFile" : "assets/js/modernizr-custom.js",
// Based on default settings on http://modernizr.com/download/
"extra" : {
"shiv" : true,
"printshiv" : false,
"load" : true,
"mq" : true,
"cssclasses" : true
},
// Based on default settings on http://modernizr.com/download/
"extensibility" : {
"addtest" : false,
"prefixed" : false,
"teststyles" : false,
"testprops" : false,
"testallprops" : false,
"hasevents" : false,
"prefixes" : false,
"domprefixes" : false,
"cssclassprefix": ""
},
// By default, source is uglified before saving
"uglify" : true,
// Define any tests you want to implicitly include.
"tests" : [],
// By default, this task will crawl your project for references to Modernizr tests.
// Set to false to disable.
"parseFiles" : true,
// When parseFiles = true, this task will crawl all *.js, *.css, *.scss and *.sass files,
// except files that are in node_modules/.
// You can override this by defining a "files" array below.
// "files" : {
// "src": []
// },
// This handler will be passed an array of all the test names passed to the Modernizr API, and will run after the API call has returned
// "handler": function (tests) {},
// When parseFiles = true, matchCommunityTests = true will attempt to
// match user-contributed tests.
"matchCommunityTests" : false,
// Have custom Modernizr tests? Add paths to their location here.
"customTests" : []
}
},
// Move bower components to desired directories
bowercopy: {
options: {
srcPrefix: 'bower_components'
},
scripts: {
options: {
destPrefix: 'assets'
},
files: {
'js/modernizr.js': 'modernizr/modernizr.js',
'css/compass': 'compass-mixins/lib'
}
}
}
});
// Uglify and concat
grunt.registerTask("uglicat", ["uglify", "concat"])
// Default task
grunt.registerTask('default', ['watch']);
// Build task
grunt.registerTask('build', function() {
var arr = ['jshint'];
if (hasSass) {
arr.push('sass:production');
}
if (hasStylus) {
arr.push('stylus:production');
}
arr.push('autoprefixer', 'cssmin', 'imagemin:production', 'svgmin:production', 'requirejs:production', 'uglify', 'concat', 'modernizr:dist');
return arr;
});
// Template Setup Task
grunt.registerTask('setup', function() {
var arr = [];
if (hasSass) {
arr.push['sass:dev'];
}
if (hasStylus) {
arr.push('stylus:dev');
}
arr.push('bower-install');
});
// Load up tasks
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-svgmin');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks("grunt-modernizr");
grunt.loadNpmTasks('grunt-bowercopy');
grunt.loadNpmTasks('grunt-grunticon');
// Run bower install
grunt.registerTask('bower-install', function() {
var done = this.async();
var bower = require('bower').commands;
bower.install().on('end', function(data) {
done();
}).on('data', function(data) {
console.log(data);
}).on('error', function(err) {
console.error(err);
done();
});
});
}
else if (environment == "steve") {
}
};