rollup-stream

This is a simple wrapper around Rollup that returns a readable stream instead
of a Promise, like Browserify's bundle() method. It's designed to make using
Rollup with gulp easier, but if you find another use for it, go ahead!
The options object is passed to Rollup's rollup() and generate() methods. This
currently works because there's no overlap between the names of the options
those methods take. Hopefully that won't change any time soon!
Installation
npm install --save-dev rollup-stream
Basic usage
var gulp = require('gulp'),
rollup = require('rollup-stream'),
source = require('vinyl-source-stream');
gulp.task('rollup', function() {
return rollup({
input: './src/main.js'
})
.pipe(source('app.js'))
.pipe(gulp.dest('./dist'));
});
Usage with sourcemaps
var gulp = require('gulp'),
rollup = require('rollup-stream'),
sourcemaps = require('gulp-sourcemaps'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer');
gulp.task('rollup', function() {
return rollup({
input: './src/main.js',
sourcemap: true
})
.pipe(source('main.js', './src'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist'));
});
Usage with caching
var gulp = require('gulp'),
rollup = require('rollup-stream'),
source = require('vinyl-source-stream');
var cache;
gulp.task('rollup', function() {
return rollup({
input: './src/main.js',
cache: cache
})
.on('bundle', function(bundle) {
cache = bundle;
})
.pipe(source('app.js'))
.pipe(gulp.dest('./dist'));
});
gulp.task('watch', function() {
gulp.watch('./src/**/*.js', ['rollup']);
});
Usage with newer, older, or custom Rollup
var gulp = require('gulp'),
rollup = require('rollup-stream'),
source = require('vinyl-source-stream');
gulp.task('rollup', function() {
return rollup({
input: './src/main.js',
rollup: require('rollup')
})
.pipe(source('app.js'))
.pipe(gulp.dest('./dist'));
});
Usage with Rollup config file
var gulp = require('gulp'),
rollup = require('rollup-stream'),
source = require('vinyl-source-stream');
gulp.task('rollup', function() {
return rollup('rollup.config.js')
.pipe(source('app.js'))
.pipe(gulp.dest('./dist'));
});