What is broccoli-funnel?
broccoli-funnel is a Broccoli plugin that allows you to filter and move files around within a Broccoli build pipeline. It is commonly used to include or exclude specific files or directories, rename files, and restructure the output directory tree.
What are broccoli-funnel's main functionalities?
Filtering Files
This feature allows you to filter files based on a pattern. In this example, only JavaScript files from the 'src' directory are included in the output.
const Funnel = require('broccoli-funnel');
const filteredTree = new Funnel('src', {
include: ['**/*.js']
});
Excluding Files
This feature allows you to exclude files based on a pattern. In this example, all test JavaScript files are excluded from the 'src' directory.
const Funnel = require('broccoli-funnel');
const filteredTree = new Funnel('src', {
exclude: ['**/*.test.js']
});
Renaming Files
This feature allows you to rename files during the build process. In this example, 'index.html' is renamed to 'main.html'.
const Funnel = require('broccoli-funnel');
const renamedTree = new Funnel('src', {
getDestinationPath: function(relativePath) {
if (relativePath === 'index.html') {
return 'main.html';
}
return relativePath;
}
});
Moving Files
This feature allows you to move files to a different directory. In this example, all files from the 'src' directory are moved to the 'output' directory.
const Funnel = require('broccoli-funnel');
const movedTree = new Funnel('src', {
destDir: 'output'
});
Other packages similar to broccoli-funnel
broccoli-merge-trees
broccoli-merge-trees is a Broccoli plugin that allows you to merge multiple trees into a single tree. It is useful for combining the output of different Broccoli plugins. Unlike broccoli-funnel, which focuses on filtering and moving files, broccoli-merge-trees is used for combining multiple sets of files.
broccoli-stew
broccoli-stew is a collection of Broccoli plugins that provide various utilities for working with Broccoli trees. It includes functionality for debugging, filtering, and transforming files. While broccoli-funnel focuses on filtering and moving files, broccoli-stew offers a broader range of utilities.
broccoli-concat
broccoli-concat is a Broccoli plugin that concatenates multiple files into a single file. It is useful for bundling JavaScript or CSS files. Unlike broccoli-funnel, which is used for filtering and moving files, broccoli-concat is specifically designed for concatenation.
Broccoli Funnel
Broccoli plugin that allows you to filter files selected from an input tree down based on regular expressions.
Inspired by broccoli-static-compiler.
Documentation
Funnel(inputTree, options)
inputTrees
{Single Tree}
Can either be a single tree, or an array of trees. If an array was specified, an array of source paths will be provided when
calling updateCache
.
Options
srcDir
{String}
A string representing the portion of the input tree to start the funneling from. This will be the base path for filtering regexp's.
Default: root path of input tree
destDir
{String}
A string representing the destination path.
Default: root path of input tree
include
{Array of RegExps}
An array of regular expressions that files and directories in the input tree must pass (match at least one pattern) in order to be included in the cache hash for rebuilds. In other words, a whitelist of patterns that identify which files and/or directories can trigger a rebuild.
Default: []
exclude
{Array of RegExps}
An array of regular expressions that files and directories in the input tree cannot pass in order to be included in the cache hash for rebuilds. In other words, a blacklist of patterns that identify which files and/or directories will never trigger a rebuild.
Note, in the case when a file or directory matches both an include and exlude pattern, the exclude pattern wins
Default: []
ZOMG!!! TESTS?!?!!?
I know, right?
Running the tests:
npm install
npm test
License
This project is distributed under the MIT license.