Skip to content

Instantly share code, notes, and snippets.

@toddlucas
Last active December 23, 2019 17:09
Show Gist options
  • Save toddlucas/b8b80d55af8e837475fbf1ba6efed910 to your computer and use it in GitHub Desktop.
Save toddlucas/b8b80d55af8e837475fbf1ba6efed910 to your computer and use it in GitHub Desktop.
Build multiple app bundles with Gulp and Browserify (vendor bundle not included here)
const paths = {
entries: {
ts: [
"Scripts/app.ts"
]
},
...
};
/**
* Build one or more app bundles that share a common vendor file.
*
* @returns {MergedStream} Merged stream
*/
function app() {
const tasks = paths.entries.ts.map(function (entry) {
const browse = browserify({
debug: true,
entries: [entry]
});
return browse
.plugin(tsify)
.external(paths.input.files.vendors)
.bundle()
.pipe(source(entry))
.pipe(rename({
dirname: "",
extname: ".js"
}));
});
return es.merge.apply(null, tasks)
.pipe(gulp.dest(paths.output.dirs.wwwscripts))
.pipe(buffer())
.pipe(terser())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(paths.output.dirs.wwwscripts));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment