1
votes

Just getting started with requirejs. I have a main app.js script in which I've set up my require.config etc. I want my file structure to look like this:

index.html
/js
    app.js
    /partials
        jquery-functions.js
        lightslider-functions.js

Wherein the actual custom scripts are being held in partial files that are specific to plugins/libs, and get called from app.js with all the correct dependencies. How do I define a module with a different-than-standard relative path?

require.config({
baseUrl: '../js',
shim: {
    lightslider: {
        deps: [
            'jquery'
        ]
    },
    featherlight: {
        deps: [
            'jquery'
        ]
    }
},
paths: {
    'jquery': [
        // CDN
        '//code.jquery.com/jquery-1.11.3.min',
        // LOCAL FALLBACK
        'libs/jquery/jquery-1.11.3.min'
    ],
    'featherlight': [
        // CDN
        '//cdn.rawgit.com/noelboss/featherlight/1.3.4/release/featherlight.min',
        // LOCAL FALLBACK
        'libs/featherlight/featherlight.min'
    ],
    'pikaday': [
        'libs/pikaday/pikaday'
    ],
    'lightslider': [
        'libs/lightslider/lightslider.min'
    ],
    'modernizr': [
        // CDN
        '//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr',
        // LOCAL FALLBACK
        'libs/modernizr/modernizr'
    ]
},
});
1
Can you post your present require.config? - zero298
@zero298 Yes I've done that now. - j_d

1 Answers

-1
votes

Locations are always evaluated with reference to the baseUrl unless they start with a / or a protocol (e.g. https://).

I would suggest having baseUrl as your uppermost, root path and creating packages with sublinks where necessary.