From 98ae511ae8aa89b934e0e07ee70ef23e9c9ce99f Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Mon, 11 Jul 2016 16:41:05 +0200 Subject: [PATCH] Add require relative load support To use local AMD modules within extra.d plugins, the relative URL for the global requireJS configuration makes this a bit difficult. To solve this the following code can be added to plugin files, before the first define call. ``` require.config({ paths: { 'extra.d': '../../../extra.d', } }) define(['./local-module'], function(localModule) { /* ... */ }); ``` This change adds this configuration by default, so it is no longer required to have it in each plugin which want to use './local-module' syntax in require or define. As all plugins loaded via `extra.d` folder are inside `extra.d` this automatically means that the URLs are resolved correctly from the extra.d base URL as defined by the plugin itself. --- static/js/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/js/main.js b/static/js/main.js index b43dd87f..35dc34f2 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -56,7 +56,9 @@ require.config({ 'partials': '../partials', 'sounds': '../sounds', - 'translation': '../translation' + 'translation': '../translation', + + 'extra.d': '../../../extra.d' }, shim: { 'modernizr': {