Gruntfile.js 983 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* jshint node:true */
  2. 'use strict';
  3. module.exports = function (grunt) {
  4. var config = {
  5. pkg: grunt.file.readJSON('package.json'),
  6. baseDir: '.',
  7. srcDir: 'src',
  8. destDir: 'dist',
  9. tempDir: 'tmp',
  10. };
  11. // load plugins
  12. require('load-grunt-tasks')(grunt);
  13. // load task definitions
  14. grunt.loadTasks('tasks');
  15. // Utility function to load plugin settings into config
  16. function loadConfig(config,path) {
  17. require('glob').sync('*', {cwd: path}).forEach(function(option) {
  18. var key = option.replace(/\.js$/,'');
  19. // If key already exists, extend it. It is your responsibility to avoid naming collisions
  20. config[key] = config[key] || {};
  21. grunt.util._.extend(config[key], require(path + option)(config,grunt));
  22. });
  23. // technically not required
  24. return config;
  25. }
  26. // Merge that object with what with whatever we have here
  27. loadConfig(config,'./tasks/options/');
  28. // pass the config to grunt
  29. grunt.initConfig(config);
  30. };