title: gruntjs load external config
body: <p>Ahoy grunt-masters!</p>
  
  <p>I would like to load external config files into grunt so that I can do something like this:</p>
  
  <p><code>$ grunt dev:homepage</code></p>
  
  <p>and it would load in <code>homepage-config.json</code>, then run <code>watch</code></p>
  
  <p><code>$ grunt dev:contact</code></p>
  
  <p>and it would load in <code>contact-config.json</code>, then run <code>watch</code></p>
  
  <p>Each config file would provide a particular setup for tasks: watch, jshint, concat, etc...</p>
  
  <p>Inside my Gruntfile I have a task called <code>dev</code></p>
  
  <pre><code>grunt.registerTask('dev', 'loads in external -config.json file, then runs watch', function(name) {
  
    grunt.initConfig(grunt.file.readJSON(name + '-config.json'));
  
    console.log(grunt.config('jshint.pageConfig.src') // correctly logs whatever had been specified in my external json file
  
    grunt.task.run('watch'); // correctly boots up watch with configuration specified by external file
  
  });
  </code></pre>
  
  <p>Within that <code>dev</code> task the externally loaded config works just fine. That console.log would return what you'd expect, and the <code>watch</code> task kicks off with the externally specified setup.</p>
  
  <p>My problem is that once that <code>watch</code> starts triggering tasks, those tasks no longer seem to have access to this externally loaded config. Somewhere between the <code>dev</code> task and the tasks triggered by <code>watch</code>, the dynamically loaded config gets blown away.</p>
  
  <p>Can anyone shed light on why this is happening and how I might accomplish my goal?</p>
  
  <p>Many thanks,
  -James</p>