gulp-browser/index.js

38 lines
1.2 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
2015-10-24 18:55:14 +00:00
/// <reference path="./index.ts" />
2015-10-24 16:26:41 +00:00
var GulpBrowserBrowserify;
(function (GulpBrowserBrowserify) {
function init() {
return function () {
return plugins.through.obj(function (file, enc, cb) {
2015-10-26 22:27:33 +00:00
var bundleCallback = function (err, bufferedContent) {
if (Buffer.isBuffer(bufferedContent)) {
file.contents = bufferedContent;
}
else {
plugins.beautylog.error("gulp-browser: .browserify() " + err.message);
}
2015-10-26 22:27:33 +00:00
cb(null, file);
2015-10-24 18:55:14 +00:00
};
plugins.browserify(file)
2015-10-26 22:27:33 +00:00
.bundle(bundleCallback);
2015-10-24 16:26:41 +00:00
});
};
}
GulpBrowserBrowserify.init = init;
})(GulpBrowserBrowserify || (GulpBrowserBrowserify = {}));
/// <reference path="./typings/main.d.ts" />
2015-10-24 16:26:41 +00:00
/// <reference path="./modulebrowserify.ts" />
var plugins = {
beautylog: require("beautylog"),
through: require("through2"),
gutil: require("gulp-util"),
path: require("path"),
browserify: require("browserify")
};
2015-10-24 16:26:41 +00:00
//create the return object
var gulpBrowser = {};
gulpBrowser.browserify = GulpBrowserBrowserify.init();
module.exports = gulpBrowser;