npm-install-loader
Webpack loader to automatically npm install & save dependencies.
Last updated 5 years ago by ericclemmons .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install npm-install-loader 
SYNC missed versions from official npm registry.

npm-install-loader

Webpack loader to automatically npm install & save dependencies.

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 install missing dependencies between reloads.

Usage

In your webpack.config.js:

module: {
  postLoaders: [
    {
      exclude: /node_modules/,
      loader: "npm-install-loader",
      test: /\.js$/,
    },
  ],
}

This will ensure that any other loaders (e.g. eslint-loader, babel-loader, etc.) have completed.

Saving

This loader simply runs npm install [modules].

I recommend creating an .npmrc file in the root of your project with:

save=true

This will automatically save any dependencies anytime you run npm install (no need to pass --save).

Alternatively, you can provide CLI arguments that get added directly to npm install:

postLoaders: [
  {
    exclude: /node_modules/,
    loader: "npm-install-loader",
    query: {
      cli: {
        registry: "..."   // --registry='...'
        save: true,       // --save
        saveExact: true,  // --save-exact
      },
    },
    test: /\.js$/,
  },
],


### License

> MIT License 2015 © Eric Clemmons

Current Tags

  • 1.1.1                                ...           latest (5 years ago)

5 Versions

  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 6
Dependencies (4)
Dev Dependencies (4)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |