-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
executable file
·66 lines (54 loc) · 2.27 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
module.exports = function (grunt) {
var _ = require('lodash');
// Utility function
global.stringify = function (object) {
return JSON.stringify(object, null, ' ');
};
// Load grunt tasks on demand —> Better build time
require('jit-grunt')(grunt, {
'sass_compile_imports': 'grunt-sass-compile-imports',
'bump-only': 'grunt-bump-cordova',
'bump-commit': 'grunt-bump-cordova'
});
// Will print the time taken by each task at the end of process
require('time-grunt')(grunt);
// Current task name
var taskName = _.get(grunt.cli, 'tasks[0]') || 'default';
// Load patterns file in conf/ folder.
// You can choose which conf file will be loaded from `conf/` folder with option `patterns`.
// Example: `grunt --patterns dist` will load `conf/dist.js`
// Default value is `dev`.
var patternsFileName = grunt.option('patterns');
// If not provided...
if (!patternsFileName) {
// ... shorcut to use the dev file for default task, and dist file for the dist one.
// So, writing `grunt dist` is equivalent to `grunt dist --patterns dist`
patternsFileName = taskName === 'dist' ? 'dist' : 'dev';
}
var patterns = require('./conf/' + patternsFileName + '.js');
// Pseudo private property for grunt tasks.
patterns._name = patternsFileName;
grunt.verbose.writeln('Loaded patterns from conf/' + patternsFileName + '.js: ' + stringify(patterns));
var options = {
config: {src: "grunt/*.js"},
src: 'app',
tmp: '.tmp',
pub: 'www',
vendor: 'vendor',
patterns: patterns
};
// Loads the various task configuration files
var configs = require('load-grunt-configs')(grunt, options);
grunt.initConfig(configs);
// Register task aliases from aliases.yaml.
grunt.verbose.writeln('Loading aliases…');
yaml = require('js-yaml');
fs = require('fs');
var _ = require('lodash');
var aliases = yaml.safeLoad(fs.readFileSync('grunt/aliases.yaml', 'utf8'));
grunt.verbose.writeln('Aliases: ' + stringify(aliases) + '\n');
_.forEach(aliases, function (value, key) {
grunt.verbose.writeln('Registered task ' + key + ': ' + value + '\n');
grunt.registerTask(key, value);
});
};