Skip to content

Instantly share code, notes, and snippets.

@jwhitley
Created March 28, 2012 20:41
Show Gist options
  • Save jwhitley/2230350 to your computer and use it in GitHub Desktop.
Save jwhitley/2230350 to your computer and use it in GitHub Desktop.
r.js driver script w/ optimize: none
//Load the requirejs optimizer
var requirejs = require('/Users/whitley/src/requirejs-rails/bin/r.js'),
//Set up basic config, include config that is
//common to all the optimize() calls.
basConfig = {
"baseUrl": "/Users/whitley/tmp/wombat/tmp/assets",
"optimize": "none",
"paths": {
"d3": "d3.v2"
}
};
// Function used to mix in baseConfig to a new config target
function mix(target) {
for (var prop in basConfig) {
if (basConfig.hasOwnProperty(prop)) {
target[prop] = basConfig[prop];
}
}
return target;
}
var module_specs = [
{
"name": "application",
"out": "/Users/whitley/tmp/wombat/public/assets/application.js"
},
{
"name": "charts",
"out": "/Users/whitley/tmp/wombat/public/assets/charts.js"
},
];
// Do a series of builds of individual files, using the args suggested by:
// http://requirejs.org/docs/optimization.html#onejs
//
// r.js will eventually need a nested call idiom to handle async
// builds. Anticipating that need.
var async_runner = module_specs.reduceRight(function(prev, curr) {
return function (buildReportText) {
requirejs.optimize(mix(curr), prev);
};
}, function(buildReportText) {} );
async_runner();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment