jsoverson/grunt-template-jasmine-requirejs — pull request #30 by zdennis (2013-07-01 22:14:21+00:00)
Title: Better Support for requireConfig and requireConfigFile

This pull request adds the following features:

* `requireConfigFile` now supports an array of config file paths. It will load from left to right.
* `requireConfig` is now applied last and deep-merged onto the config from `requireConfigFile` (if it is supplied).
* Added requireJS 2.1.6 support

This allows someone to have a single main config and then to provide additional configs which are used as overrides. This reduces the workload when you want to have slightly different config values for different environments as you no longer have to copy and paste the entire requireJS config (which can be lengthy).

### Example

Take the following config in a Gruntfile:

templateOptions: {
requireConfigFile: ['src/mainConfig.js', 'test/config.js'],
requireConfig: {
param: 'this will override any param set in config files specified above'
}
}

In the above, `src/mainConfig.js` will be loaded as the base/full requireJS config. It gets loaded first, then `test/config.js` is loaded and is deep-merged onto the currently loaded config. The `test/config.js` may only be a partial requireJS config. For example, the following `test/config.js` supplies an override for the `app/core/dom` path from `mainConfig.js`:

require.config({
paths: {
"app/core/dom": "../spec/spec_helpers/fakes/fake-dom"
}
});

This uses the built-in grunt deep merge capabilities (via [Lo-Dash](http://www.lodash.com/docs#merge)) so you can override any value whether it's a top-level key or a low-level shim. And any number of files are supported for whatever a project's needs are.

Additionally, `requireConfig` can be used in combination with `requireConfigFile`. If both are supplied then `requireConfigFile` is loaded first (with multiple files loaded from left to right) and then lastly `requireConfig` will be deep-merged onto those.