Created
December 16, 2011 21:18
-
-
Save jwhitley/1488036 to your computer and use it in GitHub Desktop.
This file contains 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/src/foo/tmp/assets", | |
"modules": [ | |
{ | |
"name": "application" | |
}, | |
{ | |
"name": "hello" | |
} | |
] | |
}; | |
// 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/src/foo/public/assets/application.js' | |
}, | |
{ | |
name: "hello", | |
out: '/Users/whitley/src/foo/public/assets/hello.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