Broccoli plugin to merge multiple files into one or multiple files
npm install broccoli-merge-files






Merge multiple trees of files into one or multiple files with a user-provided
merge function.
``bash`
yarn add -D broccoli-merge-files
`ts
const { BroccoliMergeFiles } = require('broccoli-merge-files');
const mergedNode = new BroccoliMergeFiles(inputNodes, {
merge: entries => JSON.stringify(Object.fromEntries(entries))
});
`
- inputNodes: An array of nodes, whose contents will be merged
- options: A hash of options
- outputFileName?: string: Optional output file name, if merge returnsasync merge(files: [fileName, contents][])
just the file singular file contents.
- : Called with an array of alloutputFileName
files to be merged.
- If is set, expected to return a string or Buffer.[fileName, contents][]
- If it is not set, expected to return an array or output files, like:
, where fileName is a string and contents is astring
or Buffer.sort
- :true
- _(default)_: Sort in order of input nodes and then relative filefalse
path.
- : Skip any sorting. Must not be used in conjunction withDuplicateStrategy.KeepFirst
or DuplicateStrategy.KeepLast.(a: Entry, b: Entry) => number
- : Compare function that gets[].sort()
passed two entries. Basically what you would pass to .duplicates
- : If multiple input nodes contain a file with the same'prohibit'
relative file path...
- _(default)_: an error will be thrown and the pipeline crashes.'keep-first'
- : the file from the first input node containing it is kept.'keep-last'
- : the file from the last input node containing it is kept.'keep-all'
- : all files will be passed through to merge.async transformFile?(path: string, contents: string | Buffer): any
- merge
_(optional)_: Lets you transform every file before passing it to .patterns?: string | string[]
- : Glob patterns forfast-glob
.globOptions?: object
- : Glob options forfast-glob
.encoding?: string = 'utf8'
- : The encoding to use when reading and writingannotation?: string
files.
- : A note to help tell multiple plugin instances apart.
- broccoli-merge-trees
— Copies multiple trees of files on top of each other, resulting in a single
merged tree. Does not merge any individual files.
- broccoli-flatiron
— Takes in a single input tree and merges all input files into a single JS
module. Since this plugin is deprecated and not maintained any more,
broccoli-merge-files includes a compatibility util to do the same thing:
`js
const { BroccoliMergeFiles } = require('broccoli-merge-files');
const flatiron = require('broccoli-merge-files/flatiron');
new BroccoliMergeFiles([inputNode], {
merge: files =>
flatiron(files, {
// trimExtensions: false,
// prefix: 'export default ',
// suffix: ';'
}),
outputFileName: 'files.js'
});
``