Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sane Gruntfile.js organization.
module.exports = function(grunt) {
var config = {};
// Set all the tasks you want to load.
var tasks = [
, "grunt-contrib-concat"
, "grunt-contrib-uglify"
, "grunt-contrib-jshint"
, "grunt-contrib-watch"
];
// Minify JavaScript.
config.uglify = {};
config.uglify.dist = {
options: {report: "gzip"}
, files: {
"pin.min.js": "pin.js"
}
};
// Concatenate files.
config.concat = {};
config.concat.dev = {
files: {
"pin.js": [
"pin/vendor/emitter.js"
, "pin/vendor/module.js"
, "pin/model.js"
, "pin/helpers.js"
, "pin/view.js"
]
}
};
// Set up jshint.
config.jshint = {};
config.jshint.dist = {
options: {jshintrc: ".jshintrc"}
, files: {
all: ["pin/*.js"]
}
};
config.jshint.dev = {
options: {jshintrc: ".jshintrc.dev"}
, files: {
all: ["pin/*.js"]
}
};
// Set up the watch rules.
config.watch = {};
config.watch.scripts = {
files: ["pin/**/*.{css,scss,js,hbs}"]
, tasks: ["dev"]
};
// Register the development task.
grunt.registerTask("dev", ["jshint:dev", "concat:dev"]);
// Register the production task.
grunt.registerTask("build", ["jshint:dist", "concat:dev", "uglify"]);
// Initialize Grunt and load all tasks.
grunt.initConfig(config);
tasks.forEach(grunt.loadNpmTasks);
// Set default task.
grunt.registerTask("default", ["dev"]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.