Movatterモバイル変換


[0]ホーム

URL:


webpack logo
ag grid
ag charts

InstallWebpackPlugin

Disclaimer: InstallWebpackPlugin is a third-party package maintained by community members, it potentially does not have the same support, security policy or license as webpack, and it is not maintained by webpack.

npmdepstestcoveragechat

Speed up development byautomatically installing & saving dependencies with Webpack.

It is inefficient toCtrl-C yourbuild script & server just to installa dependency you didn't know you needed until now.

Instead, userequire orimport how you normally would and installationwill happenautomatically to install & save missing dependencies while you work!

$npminstall --save-dev install-webpack-plugin

Usage

In yourwebpack.config.js:

plugins:[newInstallPlugin()],

This is equivalent to:

plugins:[newInstallPlugin({    dependencies:{      peer:true,},    packageManager:{      type:this.getDefaultPackageManager(),      options:{        dev:false,        quiet:false,},},    prompt:true,});],

Options

dependencies

Type:Object

Dependencies related options.

peer

Type:Boolean

Default:true

Install missing peer dependencies.

plugins:[newInstallPlugin({    dependencies:{      peer:true,}}),],

packageManager

Type:'npm' | 'yarn' | 'pnpm' | Object | Function

Package manager to use for installing dependencies.

plugins:[newInstallPlugin({      packageManager:'yarn'},}),],

You can provide aFunction to thepackageManager to make it dynamic:

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

type

Type:'npm' | 'yarn' | 'pnpm'

Name of package manager to use for installing dependencies.

options

Type:Object

Package manager related options.

arguments

Type:Array

Provide custom arguments to use with package manager.

plugins:[newInstallPlugin({      packageManager:{        type:'npm',        options:{          arguments:['--ignore-scripts']}}},}),],

dev

Type:Boolean

Default:false

Install as development dependencies.

plugins:[newInstallPlugin({      packageManager:{        type:'npm',        options:{          dev:true,}}},}),],

quiet

Type:Boolean

Default:false

Reduce the amount of console logging.

plugins:[newInstallPlugin({      packageManager:{        type:'npm',        options:{          quiet:true,}}},}),],

prompt

Type:Boolean

Default:true

Show a prompt to confirm installation.

plugins:[newInstallPlugin({      prompt:true,},}),],

Demo

install-webpack-plugin demo

Features

  • Works with webpack^v5.0.0.
  • Auto-installs.babelrc plugins & presets.
  • Supports both ES5 & ES6 Modules.(e.g.require,import)
  • Supports Namespaced packages.(e.g.@cycle/dom)
  • Supports Dot-delimited packages.(e.g.lodash.capitalize)
  • Supports CSS imports.(e.g.@import "~bootstrap")
  • Supports webpack loaders.(e.g.babel-loader,file-loader, etc.)
  • Supports inline webpack loaders.(e.g.require("bundle?lazy!./App")
  • Auto-installs missingpeerDependencies.(e.g.@cycle/core will automatically installrx@*)
  • Supports webpack'sresolve.alias &resolve.root configuration.(e.g.require("react") can alias toreact-lite)

Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.

CONTRIBUTING


[8]ページ先頭

©2009-2025 Movatter.jp