I've just started using RequireJS. I'm setting up a few path aliases to save me from having to specify the version number on my dependencies but it seems I can't combine a path alias with a directory alias. For example:
require.config({
baseUrl: "/js/app", // by default load any module IDs from js/app
paths: {
"libs": "/some/path/to/libs",
"jquery": "libs/jquery-1.9.0" // loads from /some/path/to/libs/jquery-1.9.0.js
}
});
require(["jquery"], function ($) {
$("#foo").html("bar");
});
RequireJS attempts to load jquery from /js/app/libs/jquery-1.9.0.js
Is this possible or would I need to define each js file path separately (if I didn't want to remove the version number)?
No, this isn't possible.
To quote James Burke's answer to a similar question in this ticket:
Paths are not additive -- the property name for a path entry is a module ID and the value is a path that is not computed from other values.
I think you do have to define each js file path separately, I can't think of a better way to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With