README
Bundles Banner Bundler
This is a bundler plugin for use with Bundles. bundles-banner prepends a file banner to the content for specified files.
Environment support
| Node | CLI | ES Module | Browser | UMD |
|---|---|---|---|---|
| ✓ | ✓ | ✓ | x | x |
Install
Make sure Bundles is installed.
npm install @bundles/bundles-banner -D
Usage
See configuring Bundles for how to configure Bundles and bundlers.
Configuration
The following properties are available in bundler.options:
include{String[]|Function} (['.js', '.css']) Determines whether filepath should include a banner. If String Array matches the file extension, or if a Function returnstrue, a banner is added.prefix{String} ('/*! ') Banner prefix.suffix{String} (' */') Banner suffix.metadata{String[]|Array[]|Function|Function[]} (['author', 'reference']) Metadata to add to banner. Each item in the Array represents a parameter name, and the value of the parameter. Each item can be a String, an Array where item[0] is the parameter's name and item[1] is the value, or a Function which returns a String or Array. See example below.joinWith{String} (' | ') Character(s) to joinmetadatawith.paramNameChar{String} ('@') Character(s) to prepend parameter name with.
Example
const bundle = {
input: [...],
bundlers: [{
run: '@bundles/bundles-banner',
include: ['.js'],
// Metadata can be String, Array, or Function.
metadata: ['author', ['my-param', 'This is my param.', (file) => {
if (file.data.myProp) return ['custom-param', 'Value is ' + file.data.myProp]
return false
}]],
joinWith: ' - '
}]
}
Assuming the following data:
author: Snoopy
myProp: true
the above example will return:
/*! @author Snoopy - @my-param This is my param. - @custom-param Value is true */