Search code examples
pluginsrequirejsbase-url

Requirejs baseurl relative


I want to set the baseurl to the folder where Require js is in, which is called js. Now I have this funny/ frustrating phenomenon that when I write

require({
        baseUrl: './'
    });

It sets the baseUrl to the url from which the document is loaded, when I set it to

 require({
        baseUrl: './js'
    });

It sets takes sets it the folder [MyProjectfoder]/js/js/ with the second js being "wrong" of course, since I want it to set it relative from my page... Any idea what I'm doing wrong?

The reason why I need is is, that I want to load plugins like the text or async plugin, which are taken form the baseurl, so if it is not the right director, the plugins can't be found.


Solution

  • Sometimes, when I write URLs, I forget which directory it is pointing to.
    Try using:

    require({
         baseUrl: 'js'
     });
    

    I hope it helps. If not, just leave a comment.