0.2.2 • Published 9 years ago

gulp-requirejs-bundle v0.2.2

Weekly downloads
7
License
-
Repository
github
Last release
9 years ago

#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.

##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.