bundle function to create a vinyl stream flowing browserify outputs.
Based on factor-bundle,
this plugin provides some sugar ways to configure factor-bundle,
b.bundle output a vinyl stream,
which flows all output file objects
to be transformed by gulp plugins.
See the files in the
var vinylify =var browserify =var path =var del =var gutil =var uglify =var gulp =var fixtures = pathresolvevar log = gutillogvar DEST =gulpgulpgulp
Specify the factor entries.
Function, it receives all the browserify entries (
and should return an array of factor entries.
If not specified, all browserify entries will be used as factor entries.
Browserify will detect a dependency graph from the inputed browserify entries. And factor-bundle will put them into several groups according to the factor entries, which are packed into bundles later.
Usually, a factor entry corresponds to a page-specific bundle. And modules shared by all page-specific bundles go to a common bundle.
As browserify entries are executed when the bundles containing them loaded, factor entries are also browserify entries at most times.
However, browserify entries that are not factor entries will go to the common bundle, and thus executed on every page. So, if you don't want to create a bundle for each browserify entry, be careful to choose the factor entries.
Each element can be either an absolte path or one relative to
b._options.basedir (not necessarily
NOTE: browserify entries metioned here are only those directly passed to the browserify constructor,
not including those added by
Specify the output file paths. You can also use gulp-rename to do this job instead.
Function, it receives the factor entries,
and should return an array of file paths.
The outputs array should pair with the factor entries array.
Each element will be used as the file path for the corresponding factor bundle.
It could be an absolute path,
or one relative to
Each output file path will be passed to vinyl-source-stream as the first argument,
options.basedir as the second,
to create a vinyl stream.
Passed to vinyl-source-stream as the second argument to create a vinyl stream.
If not specified,
b._options.basedir will be used.
Specify which files go to the common bundle.
Passed to multimatch, and matched files are put into the common bundle.
Any matched files are put into the common bundle.
It serves the same purpose with factor-bundle#threshold, and they share the same signature.
The file path for the common bundle.
To enable the factor-bundle plugin,
specify one of
if you want to use the default entries and outputs options,
you probably need to specify
Also, if you want to suppress the common bundle:
As stated in #51, if a deduped module is not packed into the same bundle with the module it is deduped against, the deduped module won't work. So we put all dedupe into the common bundle to avoid that problem.
If you do want entries go to the common bundle, specify a proper threshold option.
true, entries will never be deduped.