Search code examples
requirejsbundler.js

require.js and bundles


I created bundle config in my main configuration file

    bundles: {
        'staff-bundle-view-profile' : [
            'viewProfile/viewProfile',
            'viewProfile/viewProfileEducation',
            'viewProfile/viewProfilePublication',
            'viewProfile/viewProfilePlot'                
        ]
    }

When I try load one of modules from above list, for example viewProfile/viewProfile - as a result, require.js try load staff-bundle-view-profile.js

Of course I get 404 error. What should i do to create this file?


Solution

  • The bundles configuration option is meant to be used to load bundles created with the r.js optimizer, or any optimizer that operates like r.js does. So you need to use an optimizer like r.js to create staff-bundle-view-profile. There are multiple ways to perform the build. Which way would be best depends on specifics of your project that are not in your question. You should read the documentation and the questions about r.js already asked on SO to figure out what would work best for you.