npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-multibundle-requirejs

v4.0.0

Published

Grunt task for handling multi-bundle requirejs setup

Downloads

26

Readme

grunt-multibundle-requirejs

Grunt task for handling multi-bundle requirejs setup

Build Status bitHound Overall Score Join the chat at https://gitter.im/trulia/grunt-multibundle-requirejs

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:

grunt.loadNpmTasks('grunt-multibundle-requirejs');

The "multibundle_requirejs" task

Overview

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

grunt.initConfig({
  'multibundle-requirejs': {
    options: {
      _config: {
        // task "global" options
      },

      bundle_one: [
        // bundle specific config go here
      ],

      bundle_two: [
        // bundle specific config go here
      ]
    }
  },
});

Options

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

options._config

Type: Object

"Global" config object for the task

options.[bundle_name]

Type: Array

List of modules to bundle into [bundle_name].

_config object

_config.logLevel

Type: Number Default value: 1

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

_config.destination

Type: String Default value: undefined

Output folder for the bundles.

_config.sharedBundles

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.

_config.hashFiles

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.

_config.handleMapping

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.

_config.baseUrl

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.

_config.optimize

Type: String Default value: none

Minifier option, passed to r.js.

_config.paths

Type: Object Default value: undefined

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

_config.preserveLicenseComments

Type: Boolean Default value: false

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

[bundle] list

[bundle].[filepath]

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

Adds specified file to the parent bundle.

[bundle].[glob_mask]

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

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

[bundle].[simple_object]

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

Adds named module from specified filepath to the parent bundle.

[bundle].[feature_object]

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.

Contributing

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.