3

I am using a 'mainConfigFile' between my development require.js environment and the r.js build tools—much like the setup in the Require.js multipage example. The modules require and load fine in development, but when I try to run the same config file through r.js it searches for module paths that are one directory higher. (For example. it searches for the build version of backbone.js in build/backbone.js when it should be looking in build/vendor/backbone.js).

Here is my r.js build json config:

{
    baseUrl: "js/lib",
    mainConfigFile: 'js/lib/common.js',
    dir: 'build',
    paths: {
        'stripe': 'empty:'
    },
    modules: [
        {
            name: "common",
            include: [
                'underscore',
                'backbone',
                'backbone.validation',
                'vendor/spin',
                'vendor/transit',
                'globals'
            ]
        },
        {
            name: 'product',
            exclude: [ 'common' ]
        }
    ],
    optimize: 'none'
}

Here is my common.js shared config file located in js/lib/common.js

requirejs.config({
    baseUrl: '/js/lib',
    paths: {
        'config':       'empty:',
        'inline':       'empty:',
        'stripe':       '//js.stripe.com/v1/stripe',
        'vendor':       '../vendor',
        'underscore':       '../vendor/underscore',
        'backbone':     '../vendor/backbone',
        'backbone.validation':  '../vendor/backbone.validation',
        'text':         '../vendor/text'
    }
}); 

Finally, here is the product.js module located in js/lib/product.js which is loaded from data-main during development.

require(['./common'], function() {
    require(['./product/main', 'inline']);
}); 

The interesting problem is when I remove "../vendor/" from each of the config values—except the 'vendor' property itself—the r.js build is successful and the development data-main is unable to load the correct files. Surely I'm overlooking some config setting.

4

0 回答 0