-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
46 lines (36 loc) · 1.41 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
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);
// There are basically three phases of building the production theme:
// 1) Javascript preparation (concatenating and uglifying scripts)
grunt.registerTask('javascript', ['concat', 'uglify']);
// 2) Stylesheet preparation (SASS, autoprefixing, and minification)
grunt.registerTask('styles', ['sass', 'autoprefixer', 'cssmin']);
// 3) Appending the most recent git commit to the theme version
grunt.registerTask('release', ['gitinfo', 'replace']);
// The default task performs all three phases.
grunt.registerTask('default', ['javascript', 'styles', 'release']);
// Code analysis is handled via PHP_CodeSniffer
grunt.registerTask('analyze', ['phpcs']);
};