Created
March 28, 2012 20:41
-
-
Save jwhitley/2230350 to your computer and use it in GitHub Desktop.
r.js driver script w/ optimize: none
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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