Last active
August 29, 2015 14:07
-
-
Save danrasmuson/d287983bea13cc2c3070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm init | |
// proceed to yes a bunch | |
// download required grunt packages (for my workflow) | |
npm install grunt --save-dev | |
npm install glob --save-dev | |
npm install load-grunt-tasks --save | |
// optional packages / tasks | |
// "devDependencies": { | |
// "grunt-autoprefixer": "~0.4.1", | |
// "grunt-contrib-concat": "^0.5.0", | |
// "grunt-contrib-connect": "~0.5.0", | |
// "grunt-contrib-cssmin": "~0.7.0", | |
// "grunt-contrib-imagemin": "~0.1.2", | |
// "grunt-contrib-jshint": "~0.7.2", | |
// "grunt-contrib-sass": "~0.5.0", | |
// "grunt-contrib-uglify": "~0.2.2", | |
// "grunt-contrib-watch": "~0.5.3" | |
// }, | |
// Create this direcotry - your additiontal tasks will go into options | |
// folder structure | |
// root | |
// tasks | |
// options | |
// Creat a 'GruntFile.js' in root that contains this | |
// ------------------------ | |
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']); | |
// grunt.registerTask('default', ['concat', 'uglify', 'imagemin', 'autoprefixer', 'cssmin']); | |
grunt.registerTask('default', ['concat']); | |
// Moved to the tasks folder: | |
// grunt.registerTask('dev', ['connect', 'watch']); | |
}; | |
// ------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment