OpenSourceWorkflow / generator-kickstart

[deprecated]: yeoman generator for website development
MIT License
10 stars 1 forks source link

Deferred js modules paths in project.js #176

Open SpikeShape opened 8 years ago

SpikeShape commented 8 years ago

I just realized that the path to my deferred JS module appears in my projectsname.js file. But does it make sense to list it there? AFAIK the path that is entered doesn't exist when I require my module during the 'runtime' - or am I missing something?

markusfalk commented 8 years ago

Can you show me your projectsname.js please?

SpikeShape commented 8 years ago

sure:

requirejs.config({
    'appdir': '../',
    'baseUrl': './',
    'paths': {
        //{{app}}
        'comp': 'app/comp/comp',
        'comp-deferred': 'app/_deferred/comp/comp',

        //{{libs}}

        'jquery.exists': 'libs/jquery.exists/jquery.exists',
        'jquery': 'libs/jquery/dist/jquery.min'
    },
    'shim': {
        'jquery.exists': ['jquery']
    }
});

requirejs(['app/main']);

So my configuration is as follows: I have a standard component comp which is just some kind of bootstrapper handling the condition when the deferred module should be required and initialized. So in my script there is a call requiring comp-deferred:

if (foo) {
  require(['comp-deferred'], function(CompDeferred) {
    CompDeferred.init();
  });
}

But there is the problem I am encountering: The path that is saved es comp-deferred does not exist. The path should be something like

'/assets/js/deferred/comp.js',

for a require statement during the 'runtime' of the website.

Or am I using your deferred modules the wrong way?