Let's say you have two tasks:
development does everything necessary for development, for example jshint, coffeescript, ... production requires optimization, css minification, ...
Then you can register a build task that checks your debug flag:
grunt.registerTask('build', 'run build', function () { var task = debugEnabled ? 'development' : 'production';
At the command line, grunt build will execute it.
Alternatively, you can use the option parameter in grunt:
grunt.registerTask('build', 'run build', function () {
At the command line, grunt build --target=production will execute it.
Edit:
I understood the question a little. The only way I can see is to separate your debug flag in a separate module:
path / to / debug.js
define(function() { return true; });
Then you create a production version (next to your tasks):
path / to / footman / tasks / debug.js
define(function() { return false; });
And in your requirejs task, specify this version:
requirejs: { options: { paths: { debug: 'path/to/grunt/tasks/debug.js' } } }