Created
September 19, 2014 12:02
-
-
Save dgellow/c15392518b2442467566 to your computer and use it in GitHub Desktop.
A browserify task, currently the factor plugin does not write expected files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var watchify = require('watchify'); | |
var browserify = require('browserify'); | |
var factor = require('factor-bundle'); | |
var bundleLogger = require('../util/bundleLogger'); | |
var handleErrors = require('../util/handleErrors'); | |
var gulp = require('gulp'); | |
var source = require('vinyl-source-stream'); | |
gulp.task('browserify', function() { | |
// Directories | |
var sourceDir = './src/js/'; | |
var buildDir = './build/js/'; | |
// Files to bundle | |
var files = ['app1', 'app2']; | |
var entryFiles = files.map(function(f) { | |
return sourceDir + f + '.js'; | |
}); | |
var outputFiles = files.map(function(f) { | |
return buildDir + f + '.js'; | |
}); | |
// Bundle arguments | |
var browserifyArgs = { | |
// needed by watchify | |
cache: {}, packageCache: {}, fullPaths: true, | |
// browserify args | |
entries: entryFiles, debug: true | |
}; | |
var b = browserify(browserifyArgs); | |
var bundler = global.isWatching ? | |
watchify(b) : | |
b; | |
var bundle = function() { | |
bundleLogger.start(); | |
return bundler | |
.plugin(factor, { o: outputFiles }) | |
.bundle() | |
.on('error', handleErrors) | |
.pipe(source('common.js')) | |
.pipe(gulp.dest(buildDir)) | |
.on('end', bundleLogger.end); | |
}; | |
if(global.isWatching) { | |
bundler.on('update', bundle); | |
} | |
return bundle(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
any luck w/ this? I am having a similar issue