Docpack.prototype.use = function()

in packages/docpack/lib/docpack.js [53:74]


Docpack.prototype.use = function(arg, handler) {
  var instance;

  if (typeof arg == 'string' && typeof handler == 'function') {
    instance = Docpack.createPlugin({
      apply: function (compiler) {
        compiler.plugin('compilation', function (compilation) {
          compilation.plugin(arg, handler);
        });
      }
    })();

  } else if (typeof arg === 'object' || (typeof arg === 'function' && !handler)) {
    instance = arg;

  } else {
    throw new TypeError('DocpackPlugin instance or (hook:String, handler:Function) should be provided');
  }

  this.plugins.push(instance);
  return this;
};