gulp-requirejs-bundle

0.2.2 • Public • Published

gulp-requirejs-bundle

Dependency Status Build Status

Information

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

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

Installation

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

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

Usage

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'
    ])
        .pipe(rjs({
            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.

Options

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

Dependents (0)

Package Sidebar

Install

npm i gulp-requirejs-bundle

Weekly Downloads

3

Version

0.2.2

License

none

Last publish

Collaborators

  • vitalyzotov