@bundles/bundles-output
v0.2.1
Published
A bundler plugin for Bundles which outputs compiled results to a user defined path(s).
Downloads
32
Maintainers
Readme
Bundles Output Bundler
This is a bundler plugin for use with Bundles. bundles-output
outputs the data and content compiled by Bundles to disk.
Environment support
| Node | CLI | ES Module | Browser | UMD | | :--: | :-: | :-------: | :-----: | :-: | | ✓ | ✓ | ✓ | x | x |
Install
Make sure Bundles core is installed.
npm install @bundles/bundles-output -D
Usage
See configuring Bundles for details on configuring Bundles.
Configuration
IMPORTANT: Unless you know what you're doing, bundles-output
should be the last bundler in the config.bundlers
Array, since it should typically run after all other bundlers have run.
The following properties are available in bundler.options
:
to
{String|Function} (required) Directory to output compiled data to. Can be a callback Function which returns a String. If return value is falsy, or is not a String, the file will not be output.root
{String} (process.cwd()) Root directory for source input paths. For example, settings of{ to: 'output', root: 'my/dir' }
with a source input of['my/dir/one.md', 'my/dir/subdir/two.md']
will output files tooutput/one.md
andoutput/subdir/two.md
.incremental
{Boolean} [true] When watching files, whether to utilize the incremental build feature (true
) or always output all files (false
).fs
Options passed to fs-extra'soutputFile
method, which are the same options passed to node fs'swriteFile
method. This, for example, gives user control over whether existing files are overwritten. Note: Theencoding
option is automatically set based on whether the file type is text/utf8 or binary.
Example
// Outputs `src/my/file.md` to `my/dir/my/file.md`.
const bundle = {
input: 'src/my/file.md',
bundlers: [
{
run: '@bundles/bundles-output',
options: {
to: 'my/dir',
root: 'src',
incremental: true,
},
},
],
};