Gruntfile.js 1004 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. docsDir: 'docs/'
  11. };
  12. // load plugins
  13. require('load-grunt-tasks')(grunt);
  14. // load task definitions
  15. grunt.loadTasks('tasks');
  16. // Utility function to load plugin settings into config
  17. function loadConfig(config,path) {
  18. require('glob').sync('*', {cwd: path}).forEach(function(option) {
  19. var key = option.replace(/\.js$/,'');
  20. // If key already exists, extend it. It is your responsibility to avoid naming collisions
  21. config[key] = config[key] || {};
  22. grunt.util._.extend(config[key], require(path + option)(config,grunt));
  23. });
  24. // technically not required
  25. return config;
  26. }
  27. // Merge that object with what with whatever we have here
  28. loadConfig(config,'./tasks/options/');
  29. // pass the config to grunt
  30. grunt.initConfig(config);
  31. };