https://github.com/miguelcastillo/bit-plugin-builder
Helper for creating bit-loader plugin configurations
https://github.com/miguelcastillo/bit-plugin-builder
Last synced: about 2 months ago
JSON representation
Helper for creating bit-loader plugin configurations
- Host: GitHub
- URL: https://github.com/miguelcastillo/bit-plugin-builder
- Owner: MiguelCastillo
- License: mit
- Created: 2016-01-08T19:08:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-23T12:07:00.000Z (almost 5 years ago)
- Last Synced: 2025-03-11T07:19:08.852Z (2 months ago)
- Language: JavaScript
- Size: 42 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DEPRECATED - This has been moved into bit-bundler as well as bit-imports and made available when registering a plugin as a function.
[](https://greenkeeper.io/)
``` javascript
var bundler = new Bitbundler({
loader: {
plugins: [
function(builder) {
return builder.configure({
extensions: ["esm"]
});
}
]
}
});
```# bit-plugin-builder
> Helper for creating bit-loader plugin configurationsPlugin builder simplifies the process of creating configurations for bit-loader plugins. It merges transforms, resolve, fetch, dependency handlers in a Plugin. It also merges match and ignore rules.
#### PluginBuilder.create(options) : PluginBuilder
Factory method to create a Plugin builder. Options can be passed in for setting the intial state of the Plugin builder.- returns PluginBuilder instance
``` javascript
var utils = require("bit-bundler-utils");var defaultOptions = {
match: {
path: /[\w]+\.(js)$/
}
};var pluginBuilder = PluginBuilder.create(defaultOptions);
```#### configure(options) : PluginBuilder
Method to configure PluginBuilder instance
- returns PluginBuilder instance (self)
``` javascript
pluginBuilder = pluginBuilder.configure({
transform: function(meta) {
console.log(meta);
}
});
```#### build() : Object
Method that creates a plugin configuration object to register plugins with the loader
- returns loader plugin configuration
``` javascript
var plugin = pluginBuilder.build();
```#### Examples
Sample plugin that loads JSON files.
``` javascript
var PluginBuilder = require("bit-bundler-utils/PluginBuilder");var defaults = {
match: {
path: /[\w]+\.(json)$/
},
dependency: function dependencyText(meta) {
return {
source: "module.exports = " + meta.source + ";"
};
}
};function textPlugin(options) {
return PluginBuilder
.create(defaults)
.configure(options)
.build();
}module.exports = textPlugin;
```License
===============Licensed under MIT