There's gulp-requirejs plugin, but it's blacklisted with the following message: "use the require.js module directly".
The docs are quite sparse, how would I best use it in conjunction with Gulp build task?
In the docs there's an example:
var requirejs = require('requirejs');
var config = {
baseUrl: '../appDir/scripts',
name: 'main',
out: '../build/main-built.js'
};
requirejs.optimize(config, function (buildResponse) {
//buildResponse is just a text output of the modules
//included. Load the built file for the contents.
//Use config.out to get the optimized file contents.
var contents = fs.readFileSync(config.out, 'utf8');
}, function(err) {
//optimization err callback
});
But that doesn't help me much... Here's my best try:
var gulp = require('gulp'),
r = require('requirejs').optimize;
var config2 = {
baseUrl: 'src/js',
name: 'config',
out: 'dist/js/main-built.js'
};
gulp.task('scripts3', function() {
gulp.src(['src/js/**/*.js'])
.pipe(r(config)
.pipe(gulp.dest(config.out))
});
But the requirejs module doesn't use streams, so it won't work.
There's also the very Gulp friendly amd-optimize but it's not the same as r.js, yet.