Created
August 28, 2012 07:49
-
-
Save everilae/3495968 to your computer and use it in GitHub Desktop.
An ugly Bootstrap AMD wrapper for Require.js optimizer
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
/* onBuildRead hooks before optimizations, which is what we need in order to | |
* fake Bootstrap having define() call | |
*/ | |
onBuildRead: function (name, path, contents) { | |
var jqueryVar = 'jqueryModule'; | |
var wrapperHead = "define('" + name + "', ['jquery'], "; | |
var wrapperTail = ");"; | |
if (name === "bootstrap") { | |
console.log("Wrapping bootstrap in " + wrapperHead + "..." + wrapperTail); | |
/* Wrap Bootstrap in an AMD module by force */ | |
contents = wrapperHead + new Function(jqueryVar, contents.replace(/window\.jQuery/g, jqueryVar)) + wrapperTail; | |
} | |
// Return contents, unmodified for most | |
return contents; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment