Speed up development by automatically installing & saving dependencies with Webpack.
It is inefficient to Ctrl-C your build script & server just to install a dependency you didn't know you needed until now.
Instead, use require or import how you normally would and npm install
will happen automatically to install & save missing dependencies while you work!
$ npm install --save-dev npm-install-webpack-plugin
在 webpack.config.js 中:
plugins: [
  new NpmInstallPlugin()
],
相当于:
plugins: [
  new NpmInstallPlugin({
    // 使用 --save 或者 --save-dev
    dev: false,
    // 安装缺少的 peerDependencies
    peerDependencies: true,
    // 减少控制台日志记录的数量
    quiet: false,
    // npm command used inside company, yarn is not supported yet
    npm: 'tnpm'
  });
],
可以提供一个 Function 来动态设置 dev:
plugins: [
  new NpmInstallPlugin({
    dev: function(module, path) {
      return [
        "babel-preset-react-hmre",
        "webpack-dev-middleware",
        "webpack-hot-middleware",
      ].indexOf(module) !== -1;
    },
  }),
],

^v1.12.0 and ^2.1.0-beta.0..babelrc plugins & presets.require, import)@cycle/dom)lodash.capitalize)@import "~bootstrap")babel-loader, file-loader, etc.)require("bundle?lazy!./App")peerDependencies.
(e.g. @cycle/core will automatically install rx@*)resolve.alias & resolve.root configuration.
(e.g. require("react") can alias to react-lite)| Eric Clemmons | Jonny Buchanan |