forked from chriscoyier/My-Grunt-Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
64 lines (45 loc) · 1.6 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
/*
TO DO
1) Reduce CSS duplication
- Ideally just a single build - global.scss turns into /build/global.css
- Can Autoprefixer output minified?
- If it can, is it as good as cssmin?
- Could Sass be used again to minify instead?
- If it can, is it as good as cssmin?
2) Better JS dependency management
- Require js?
- Can it be like the Asset Pipeline where you just do //= require "whatever.js"
3) Is HTML minification worth it?
4) Set up a Jasmine test just to try it.
5) Can this Gruntfile.js be abstracted into smaller parts?
- https://github.com/cowboy/wesbos/commit/5a2980a7818957cbaeedcd7552af9ce54e05e3fb
*/
module.exports = function(grunt) {
// Utility to load the different option files
// based on their names
function loadConfig(path) {
var glob = require('glob');
var object = {};
var key;
glob.sync('*', {cwd: path}).forEach(function(option) {
key = option.replace(/\.js$/,'');
object[key] = require(path + option);
});
return object;
}
// Initial config
var config = {
pkg: grunt.file.readJSON('package.json')
}
// Load tasks from the tasks folder
grunt.loadTasks('tasks');
// Load all the tasks options in tasks/options base on the name:
// watch.js => watch{}
grunt.util._.extend(config, loadConfig('./tasks/options/'));
grunt.initConfig(config);
require('load-grunt-tasks')(grunt);
// Default Task is basically a rebuild
grunt.registerTask('default', ['concat', 'uglify', 'sass', 'imagemin', 'autoprefixer', 'cssmin']);
// Moved to the tasks folder:
// grunt.registerTask('dev', ['connect', 'watch']);
};