Skip to content

Instantly share code, notes, and snippets.

@samvasko
Last active August 29, 2015 14:01
Show Gist options
  • Save samvasko/a18d4404eca0300a4b9d to your computer and use it in GitHub Desktop.
Save samvasko/a18d4404eca0300a4b9d to your computer and use it in GitHub Desktop.
Gulp + Browserify + Watchify setup
var gulp = require('gulp');
var watchify = require('watchify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var gutil = require('gulp-util');
gulp.task('editor', function () {
var b = browserify();
b.require('./sources/js/scribe.js', {expose: 'scribe'});
b.transform({global: true}, 'deamdify');
b.bundle()
.pipe(source('scribe.js'))
.pipe(gulp.dest('./public/js'));
});
gulp.task('scripts', function () {
var b = watchify('./sources/js/main.js');
b.exclude('scribe');
b.on('update', rebundle);
function rebundle () {
return b.bundle()
.on('error', gutil.log)
.pipe(source('main.js'))
.pipe(gulp.dest('./public/js/'));
}
return rebundle();
});
module.exports = {
Scribe: require('scribe-editor'),
//
}
@Rob-pw
Copy link

Rob-pw commented Mar 13, 2015

You beautiful human being, thanks for publishing this! I was missing {global: true} and going round in circles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment