I'm having difficultly using RequireJS on any of the subsidiary pages on my project build. The base URL is appended to the page URL and so causes 404 errors... Here is the JS:
require.config({
"baseUrl": "content/themes/my-theme",
"paths": {
"jquery": "bower_components/jquery/dist/jquery.min",
"foundation": "bower_components/foundation/js/foundation.min"
},
"shim": {
"foundation": ["jquery"]
}
});
require(['jquery', "foundation"], function($) {
$(document).foundation();
$(document).ready(function() {
console.log('Working!!');
});
});
Fair simple... So when I run this on my the root domain of my website (e.g. http://my-domain.com/), everything works fine and I get the console log of Working!! as expected. The included resources, for example jQuery, is called in to the correct URL:
http://my-domain.com/content/themes/my-theme/bower_components/jquery/dist/jquery.min.js
The problem is that when I visit an internal page, the baseURL is appended to the page URL and so it then points incorrectly, causing the file request to 404. Here's some examples of the URL's:
http://my-domain.com/about-us/content/themes/my-theme/bower_components/jquery/dist/jquery.min.js
http://my-domain.com/category/uncategorized/content/themes/my-theme/bower_components/jquery/dist/jquery.min.js
As you can see the page URL extension /about-us/ or /category/uncategorized/ is the problem.
I've looked through the documentation and must be missing the solution to the problem. Please can you point me in the right direction.