Skip to content

MiguelCastillo/bit-plugin-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED - This has been moved into bit-bundler as well as bit-imports and made available when registering a plugin as a function.

Greenkeeper badge

var bundler = new Bitbundler({
  loader: {
    plugins: [
      function(builder) {
        return builder.configure({
          extensions: ["esm"]
        });
      }
    ]
  }
});

bit-plugin-builder

Helper for creating bit-loader plugin configurations

Plugin 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
  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)
  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
  var plugin = pluginBuilder.build();

Examples

Sample plugin that loads JSON files.

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

About

Helper for creating bit-loader plugin configurations

Resources

License

Stars

Watchers

Forks

Packages

No packages published