4.0.0 • Public • Published


Grunt task for handling multi-bundle requirejs setup

Build Status bitHound Overall Score Join the chat at

Getting Started

This plugin requires Grunt ^0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-multibundle-requirejs --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:


The "multibundle_requirejs" task


In your project's Gruntfile, add a section named multibundle_requirejs to the data object passed into grunt.initConfig().

  'multibundle-requirejs': {
    options: {
      _config: {
        // task "global" options
      bundle_one: [
        // bundle specific config go here
      bundle_two: [
        // bundle specific config go here


Example file with all the options could be found here Gruntfile.js.


Type: Object

"Global" config object for the task


Type: Array

List of modules to bundle into [bundle_name].

_config object


Type: Number Default value: 1

Controls log level of the task and requirejs bundler, 4 being silent.


Type: String Default value: undefined

Output folder for the bundles.


Type: Array Default value: undefined

Defines list of the shared bundles (order matters), all the modules included in the shared bundles, will be excluded from other modules.


Type: Boolean|Function Default value: undefined

If enabled adds md5 hash (over bundle's content) to the bundle's filename. Could be a function (hashFiles(output, componentOptions)), then it will be responsible for producing content hash.


Type: Function

Accepts two arguments options - options object passed to the grunt task, and grunt - grunt instance itself.

Expected to return mapper instance, either WriteStream or a function, that will be called after each bundle creation with respective buildObject, to allow modules-bundle mapping. Will be called one extra time with no arguments after all the bundles processed. In case of WriteStream, bundler's ReadStream will piped into it. For example of the mapping write stream, see multibundle-mapper.


Type: String Default value: undefined

The root path to use for all module lookups. Passed to r.js. Also used as destination if _config.destination is omitted.


Type: String Default value: none

Minifier option, passed to r.js.


Type: Object Default value: undefined

Path mappings for module names not found directly under baseUrl. Passed to r.js.


Type: Boolean Default value: false

Controls preseces of the license comments in the minified files. Passed to r.js.

[bundle] list


Type: String Example: 'app/lib/my_module.js'

Adds specified file to the parent bundle.


Type: String Example: 'app/lib/**/*.js'

Adds all the files matched the pattern to the parent bundle.


Type: Object Example: {'main': 'assets/js/public/main'}

Adds named module from specified filepath to the parent bundle.


Type: Object Example: {'backbone': {src: 'node_modules/backbone/backbone.js', deps: ['jquery', 'underscore'], exports: 'Backbone', insertRequire: true}}

Adds named module from specified source to the parent bundle, with explicitly set dependencies. and creates shim to make it AMD-compatible by exporting global object. Also adds require call to execute module in-place.


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code before committing.

Package Sidebar


npm i grunt-multibundle-requirejs

Weekly Downloads






Last publish


  • alexindigo
  • asavant
  • ingiulio
  • purusho