I have a project with several relatively disjoint pages, each of which contains its own script entry point. These scripts are requireseveral others using commonjs syntax, and must be converted using 6to5 and bundled using a browser.
I would like to set up a gulp task that captures all the files that match the template and transfers them to the node, but I'm not sure how to transfer files from gulp.srcto browserify(filename).
My gulpfile looks like this:
var gulp = require("gulp");
var browserify = require("browserify");
var to5browserify = require("6to5-browserify");
var source = require("vinyl-source-stream");
var BUNDLES = [
"build.js",
"export.js",
"main.js"
];
gulp.task("bundle", function () {
return BUNDLES.map(function (bundle) {
return browserify("./src/" + bundle, {debug: true})
.transform(to5browserify)
.bundle()
.pipe(source(bundle))
.pipe(gulp.dest("./dist"));
});
});
gulp.task("scripts", ["bundle"]);
gulp.task("html", function () {
return gulp.src("src/**/*.html")
.pipe(gulp.dest("dist"));
});
gulp.task("styles", function () {
return gulp.src("src/**/*.css")
.pipe(gulp.dest("dist"));
});
gulp.task("default", ["scripts", "html", "styles"]);
This seems to work, but is not supported: I will add additional scripts relatively soon and do not want to add them to the array every time.
gulp.src(glob).pipe ( ) gulp.src(glob).map ( ).
gulp.src , , ?