1

As in the topic. My file structure is:

js/ 
 |- bootstrap
 |   |- module1
 |   |- module2
 |
 |- jquery.min.js
 |- main.js

and my main.js file is

requirejs.config({

    paths: {
        dropdowns : 'bootstrap/module1'
        ,fixes : 'bootstrap/module1'
    }
    ,shim: {
        'jquery.min' : ['jquery']
    }
});

requirejs(['jquery', 'dropdowns', 'fixes'], function ( $, Dropdowns, Fixes ) {

    console.log( $ );
    var fixes = new Fixes();

});

now... it throws the following error in the console:

GET http://myurl/myapp/js/jquery.js 404 (Not Found) 

as we can see it looses the dot with shim. My question is "how to load a file like 'jquery.min.js' where are dots before .js part?"

Oskar Szura
  • 2,469
  • 5
  • 32
  • 42

2 Answers2

0

That isn't how you load a file called jquery.min. This line is saying jquery.min depends on jquery, which doesn't make too much sense.

    'jquery.min' : ['jquery']

As jQuery defines an AMD module you should try this instead to specify the path

requirejs.config({

    paths: {
        dropdowns : 'bootstrap/module1'
        ,fixes : 'bootstrap/module1'
        ,jquery: 'jquery.min'
   }
});

This might give a clearer explanation http://requirejs.org/docs/jquery.html

Jim Jeffries
  • 9,841
  • 15
  • 62
  • 103
0

If you're simply trying to say "when requesting 'jquery' module, load it from 'jquery.min.js'", then your configuration should look like this:

requirejs.config({

paths: {
    dropdowns : 'bootstrap/module1'
    ,fixes : 'bootstrap/module1'
    ,jquery: 'jquery.min'
}

});

The shim part would come into play if you need to say that your other modules require jquery:

shim: {
    dropdowns: {
        deps: ['jquery']
    },
    fixes_validate: {
        deps: ['jquery']
    }
}

See also this answer for more detail on shim: Requirejs why and when to use shim config

Community
  • 1
  • 1
explunit
  • 18,967
  • 6
  • 69
  • 94