From 3810916577c7f01d83a264540b762c15804aaa0b Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Wed, 29 Oct 2014 16:01:06 -0700 Subject: [PATCH] Added --min option for grunt watch --- Gruntfile.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 8dff6cd2..7500d85c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -154,7 +154,7 @@ module.exports = function(grunt) { }, watch: { files: [ "Gruntfile.js", "src/*.js", "images/*" ], - tasks: "build" + tasks: "watchTask" }, jshint: { options: { @@ -209,6 +209,8 @@ module.exports = function(grunt) { }); // ---------- + // Bower task. + // Generates the Bower file for site-build. grunt.registerTask("bower", function() { var path = "../site-build/bower.json"; var data = grunt.file.readJSON(path); @@ -216,6 +218,18 @@ module.exports = function(grunt) { grunt.file.write(path, JSON.stringify(data, null, 2) + "\n"); }); + // ---------- + // Watch task. + // Called from the watch feature; does a full build or a minbuild, depending on + // whether you used --min on the command line. + grunt.registerTask("watchTask", function() { + if (grunt.option('min')) { + grunt.task.run("minbuild"); + } else { + grunt.task.run("build"); + } + }); + // ---------- // Build task. // Cleans out the build folder and builds the code and images into it, checking lint. @@ -226,7 +240,7 @@ module.exports = function(grunt) { // ---------- // Minimal build task. - // For use during development as desired. + // For use during development as desired. Creates only the unminified version. grunt.registerTask("minbuild", [ "git-describe", "concat", "copy:build" ]);