/load-webpack-plugins

Conveniently Lazy Load Webpack Plugins from Webpack Builtin Plugins or from Package Dependencies.

Primary LanguageJavaScriptMIT LicenseMIT

load-webpack-plugins

Conveniently Lazy Load Webpack Plugins from Webpack Builtin Plugins or from Package Dependencies.

Twitter

Build Status Greenkeeper badge

Install

  npm install --save-dev load-webpack-plugins

or using yarn

 yarn add load-webpack-plugins

Usage

Loading Webpack Builtin Plugins

Webpack Builtin plugins can be conveniently lazy loaded without remembering the nested path references.

  var $ = require('load-webpack-plugins')();
  ...
  module.exports = function() {
    ...
    plugins: [
      new $.APIPlugin(options),
      new $.DllPlugin(options),
      new $.UglifyJsPlugin(options),
    ]
    ...
  }

Please refer plugins.json for up to date list of supported plugins.

Loading from package dependencies

Given a package.json file that has webpack plugins in dependencies or devDependencies:

{
  "<d|devD>ependencies": {
    "webpack-html-plugin": "*",
    "assets-webpack-plugin": "*",
  }
}

Webpack plugins can be conveniently lazy loaded in webpack.config.js.

  var $ = require('load-webpack-plugins')();
  ...
  module.exports = function() {
    ...
    plugins: [
      new $.AssetsPlugin(options),
      new $.HtmlPlugin(options),
    ]
    ...
  }

Todo

  • Support Webpack Plugins published as Private/Scoped NPM Packages
  • Support Custom patterns for Plugins Discovery
  • Support Custom name transform function in option.

Credit

Thanks to @sindresorhus for awesome load-grunt-plugins