Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

npm-install-webpack2-plugin

ericclemmons3.8kMIT5.0.1

Webpack loader to automatically npm install & save dependencies.

webpack, webpack-plugin, npm, install

readme

npm-install-webpack-plugin

Speed up development by automatically installing & saving dependencies with Webpack.

npm-install-webpack-plugin mp4

Features

  • <input checked="" disabled="" type="checkbox"> Works with both Webpack ^v1.12.0 and ^2.1.0-beta.0.
  • <input checked="" disabled="" type="checkbox"> Auto-installs .babelrc plugins & presets.
  • <input checked="" disabled="" type="checkbox"> Supports both ES5 & ES6 Modules. (e.g. require, import)
  • <input checked="" disabled="" type="checkbox"> Supports Namespaced packages. (e.g. @cycle/dom)
  • <input checked="" disabled="" type="checkbox"> Supports Dot-delimited packages. (e.g. lodash.capitalize)
  • <input checked="" disabled="" type="checkbox"> Supports CSS imports. (e.g. @import "~bootstrap")
  • <input checked="" disabled="" type="checkbox"> Supports Webpack loaders. (e.g. babel-loader, file-loader, etc.)
  • <input checked="" disabled="" type="checkbox"> Supports inline Webpack loaders. (e.g. require("bundle?lazy!./App")
  • <input checked="" disabled="" type="checkbox"> Auto-installs missing peerDependencies. (e.g. @cycle/core will automatically install rx@*)
  • <input checked="" disabled="" type="checkbox"> Supports Webpack's resolve.alias & resolve.root configuration. (e.g. require("react") can alias to react-lite)

travis build Coverage Status version downloads MIT License


Why?

It sucks to <kbd>Ctrl-C</kbd> 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!

Installation

$ npm install --save-dev npm-install-webpack-plugin

Usage

In your webpack.config.js:

plugins: [
  new NpmInstallPlugin();
],

This is equivalent to:

plugins: [
  new NpmInstallPlugin({
    // Use --save or --save-dev
    dev: false,
    // Install missing peerDependencies
    peerDependencies: true,
    // Reduce amount of console logging
    quiet: false,
  });
],

You can provide a Function to the dev to make it dynamic:

plugins: [
  new NpmInstallPlugin({
    dev: function(module, path) {
      return [
        "babel-preset-react-hmre",
        "webpack-dev-middleware",
        "webpack-hot-middleware",
      ].indexOf(module) !== -1;
    },
  }),
],

License

MIT License 2016 © Eric Clemmons

changelog

Change Log

4.0.4 (2016-06-30)

Full Changelog

Fixed bugs:

  • Install peerDependency without version when given a range #58 (ericclemmons)

v4.0.3 (2016-06-14)

Full Changelog

Fixed bugs:

v4.0.2 (2016-06-14)

Full Changelog

Merged pull requests:

v4.0.1 (2016-06-07)

Full Changelog

Fixed bugs:

  • Fix failure to initialise package.json in Windows #52 (insin)

v4.0.0 (2016-05-23)

Full Changelog

Implemented enhancements:

  • installPeers Option #41
  • New Options (dev, peerDependencies) #13 (insin)

v3.1.4 (2016-05-20)

Full Changelog

Implemented enhancements:

v3.1.3 (2016-05-13)

Full Changelog

Implemented enhancements:

Closed issues:

  • Feature request: the dependancy should be removed if no import statements are present #46

v3.1.2 (2016-05-12)

Full Changelog

Implemented enhancements:

Fixed bugs:

Closed issues:

  • Trying to install webpack loaders with -loader in it #44

v3.1.1 (2016-04-30)

Full Changelog

Fixed bugs:

  • v3.1.0 seems to break webpack-dev-server behavior #43 (cafreeman)

v3.1.0 (2016-04-25)

Full Changelog

Implemented enhancements:

Fixed bugs:

  • webpack-dev-server doesn't find packages right after they're installed #34
  • Seems to add extra packages to package.json #26
  • Passing tests + README #39 (ericclemmons)
  • Support installation of packages with a period in their name, e.g. lodash.random #33 (insin)

Closed issues:

  • Feature request: support for webpack resolve.alias and resolve.root #31

Merged pull requests:

v3.0.0 (2016-03-08)

Full Changelog

Implemented enhancements:

Fixed bugs:

  • repeatedly installs same modules #20

Closed issues:

  • Exclude some packages #27
  • Working with relative imports using 'resolve' #24
  • Allow save/saveDev/saveExact behavior to be customized based on context #22

v2.0.2 (2016-01-31)

Full Changelog

Implemented enhancements:

  • Support loader shorthand (e.g. "babel" vs. "babel-loader") #16 (fritx)

v2.0.1 (2016-01-31)

Full Changelog

Fixed bugs:

  • Mismatch between code and documentation #18 (dlmr)

v2.0.0 (2016-01-24)

Full Changelog

Implemented enhancements:

Closed issues:

  • Transitive dependencies with npm3 #14
  • Strip webpack directives before running npm install #12
  • Missing require() pattern #11

v1.1.1 (2016-01-04)

Full Changelog

Fixed bugs:

  • Fix spawning npm on Windows #9 (insin)

v1.1.0 (2016-01-02)

Full Changelog

Implemented enhancements:

  • Use --save or --save-exact flags when installing based on loader query config #3 (insin)

v1.0.2 (2016-01-02)

Full Changelog

Implemented enhancements:

v1.0.1 (2015-12-30)

Full Changelog

Fixed bugs:

  • Support deep imports and multiple imports from the same module #4 (insin)

v1.0.0 (2015-12-29)

Implemented enhancements:

* This Change Log was automatically generated by github_changelog_generator