Last active
August 29, 2015 14:17
-
-
Save xbill82/3967864128719c7b7c77 to your computer and use it in GitHub Desktop.
Intercepting dependency with RequireJS
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
define({ | |
map:{ | |
'*': { 'nav': 'custom/header/nav.custom' } | |
} | |
}); |
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
require.config({ | |
paths: { | |
baseUrl: '/js', | |
jquery: 'vendor/jquery/jquery-1.9.1.min', // Had to give up the CDN one because of IE8 stupidity | |
jqueryNoconflict: 'vendor/jquery/jquery.noconflict', | |
'jquery.available': 'vendor/jquery/jquery.available.min', | |
underscore: 'vendor/underscore/underscore-min', | |
backbone: 'vendor/backbone/backbone-min', | |
bootstrap: //'//netdna.bootstrapcdn.com/bootstrap/3.0.0-wip/js/bootstrap.min', | |
['vendor/bootstrap/bootstrap-3RC1'], | |
// ['vendor/bootstrap/bootstrap-3-stable/js/bootstrap.min'], | |
modernizr: 'vendor/modernizr/modernizr-2.6.2.min', | |
spinjs: 'vendor/spinjs/spin.min', | |
// Require.js plugins | |
text: 'vendor/require/text', | |
templates: '../templates', | |
nav: 'views/header/nav' | |
}, | |
shim: { | |
'bootstrap': { | |
deps: ['jquery'], | |
exports: 'window.jQuery' | |
}, | |
'jquery.available': { | |
deps: ['jquery'], | |
exports: 'jQuery.fn.available' | |
} | |
}, | |
map: { | |
'jqueryNoconflict': { 'jquery': 'jquery' }, | |
'*': { 'jquery': 'jqueryNoconflict' } | |
}, | |
deps: ['jquery', 'underscore', 'bootstrap', 'backbone'] | |
}); | |
/** | |
* The entry point of the application. The AppView is instantiated and, once | |
* the initialization is complete (i.e. the AmiController is loaded), the view | |
* is rendered. | |
*/ | |
require([ | |
'views/app', | |
'router', | |
'vm' | |
], function(AppView, Router, Vm){ | |
var appView = Vm.create({}, 'AppView', AppView); | |
/** | |
* This block loads the dependency mapping for the customizations. | |
* The custom.map.js file contains a JSON object that redefines the paths of | |
* some dependencies. This allows us to introduce per-client customizations | |
* | |
* @see http://my.amisw.com/wiki/index.php/MIPortal:les_personnalisations | |
*/ | |
try{ | |
require(['custom/custom.map'], function(customMap){ | |
console.log(customMap); | |
if (customMap) | |
require.config(customMap); | |
}); | |
} catch (e) { | |
console.log('No custom map found'); | |
} | |
appView.vent.on('controllerReady', function() { | |
appView.render(); | |
Router.initialize({appView: appView}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment