Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including gulp-requirejs-bundle with all npm packages installed. Try it out:

var gulpRequirejsBundle = require("gulp-requirejs-bundle")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gulp-requirejs-bundle v0.2.2

Builds projects using require.js's optimizer. Fork of gulp-requirejs.


Dependency Status Build Status


A small, simply, very easy wrapper around the require.js optimizer to work with gulp.js with bundling support.

Description uses require.js's r.js optimizer to combine require.js AMD modules into one file
Node Version 0.10


Simply add gulp-requirejs-bundle as a dev-dependency in your package.json or run

$ npm install --save-dev gulp-requirejs-bundle


var gulp = require('gulp'),
    rjs = require('gulp-requirejs-bundle');

gulp.task('requirejsBuild', function() {

    return gulp.src([
        config.buildDir + '/**/*.js',
        config.buildDir + '/**/*.html', config.buildDir + '/**/*.json'
            paths:                   {
                'jquery':               'empty:',
                'text':                 '../vendor/requirejs-text/text',
                'domReady':             '../vendor/requirejs-domready/domReady'
            wrapShim:                true,
            useStrict:               true,
            baseUrl:                 config.buildDir,
            name:                    config.finalName + '/main',
            out:                     config.finalName + '.js',
            preserveLicenseComments: false,
            generateSourceMaps:      false,
            //stubModules:             ['text'],
            optimize:                "none"
        .pipe(gulp.dest(config.targetDir + '/js'));

Error handling

gulp-requirejs-bundle will emit errors when you don't pass an options object and if the baseUrl or out properties are undefined.

The requiere.js optimizer itself might also emit errors; unfortunately there's no way of catching them elegantly at the moment.


The options object supports the same parameters as the require.js optimizer.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free