Skip to content

Instantly share code, notes, and snippets.

@mxriverlynn
Last active December 20, 2015 21:09
Show Gist options
  • Save mxriverlynn/6195292 to your computer and use it in GitHub Desktop.
Save mxriverlynn/6195292 to your computer and use it in GitHub Desktop.
Inject Add-Ons And Plugins With RequireJS, Non-AMD Libraries And Shims
requirejs.config({
paths: {
jquery: "vendor/jquery",
rsvp: "vendor/rsvp",
kendoui: "vendor/kendo.all",
thatCoolLib: "vendor/thatCoolLib"
// ... etc
},
// ...
});
thatCoolLib.SomeType.prototype.myMethod = function(){
console.log("I'm doing cool stuff, here");
};
define([
"jquery",
"rsvp",
"kendoui",
"thatCoolLib"
], function(jquery, rsvp, thatCoolLib){
// ...
});
requirejs.config({
paths: {
jquery: "vendor/jquery",
rsvp: "vendor/rsvp",
kendoui: "vendor/kendo.all",
"thatCoolLib.original": "vendor/thatCoolLib",
thatCoolLib: "vendor/thatCoolLib.bootstrap"
// ... etc
},
// ...
});
define([
"thatCoolLib.original",
"vendor/anotherCoolFunction"
], function(thatCoolLib, antoherFunc){
thatCoolLib.SomeType.prototype.myMethod = function(){
console.log("I'm doing cool stuff, here");
};
thatCoolLib.SomeType.prototype.anotherFunc = anotherFunc;
return thatCoolLib;
});
@rhuss
Copy link

rhuss commented Aug 13, 2013

minor typo in 5.js: s/antoherFunc/anotherFunc/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment