gulp-requirejs-combine

0.7.1 • Public • Published

gulp-requirejs-combine

combine requirejs file into one file. purpose is reduce http request.

Install

Install with npm

npm install --save-dev gulp-requirejs-combine

DEMO

1.find out your config in requirejs

move config part into your gulpfile

require.config({
  baseUrl: './test/base',
  paths: {
    jsonp: 'jsonp',
    load: 'load',
    xhr: 'xhr',
    nonce: 'var/nonce',
    rquery: 'var/rquery'
  }
});

==>>

combine({
  baseUrl: './test/base',
  paths: {
    jsonp: 'jsonp',
    load: 'load',
    xhr: 'xhr',
    nonce: 'var/nonce',
    rquery: 'var/rquery'
  }
})

2.use in gulp

  • base use
var gulp = require('gulp');
var del = require('del');
var combine = require('gulp-requirejs-combine');

var paths = {
  js: [
    'test/base/base1.js',
    'test/base/base2.js'
  ],
  complicatejs: [
    'test/complicate/require.js'
  ]
};

gulp.task('clean', function (cb) {
  del(['build'], cb);
});

var baseConfig = {
  baseUrl: './test/base',
  paths: {
    jsonp: 'jsonp',
    load: 'load',
    xhr: 'xhr',
    nonce: 'var/nonce',
    rquery: 'var/rquery'
  }
};

gulp.task('default', function () {
  return gulp.src(paths.js)
    .pipe(combine(baseConfig))
    .pipe(gulp.dest('test/base/build'));
});
  • uglify
gulp.task('test:uglify', function () {
  return gulp.src(paths.js)
    .pipe(combine(baseConfig))
    .pipe(uglify())
    .pipe(gulp.dest('test/base/build'));
});
  • more demo please see gulpfile

3.be careful about config

config is base on your gulpfile path. your need to config it base on your gulpfile location.

var config={
  baseUrl: './test/base',//base on where your gulpfile location.
  paths: {...
  }
}

4.run demo

  • install dependencies
npm install gulp -g
npm install 
  • run demo
gulp
gulp test:base
gulp test:complicate

Problem

You are welcome to contribute

Any problem you can task issue or contact me :andy.lv@live.com

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.7.16latest

Version History

VersionDownloads (Last 7 Days)Published
0.7.16
0.6.10
0.5.10
0.1.00
0.0.10

Package Sidebar

Install

npm i gulp-requirejs-combine

Weekly Downloads

1

Version

0.7.1

License

MIT

Last publish

Collaborators

  • microlv