webpack-plugin-replace-module

1.0.0 • Public • Published

webpack-plugin-replace-module

Webpack plugin for modifying imported modules.

Installation

NPM

npm i -D webpack-plugin-replace-module

YARN

yarn add -D webpack-plugin-replace-module

CJS

const WebpackPluginReplaceModule = require("webpack-plugin-replace-module");

Usage

webpack.config.js
module.exports = {
  plugins: [
    new WebpackPluginReplaceModule({
      rules: [
        {
          originModule: "npm-a",
          replaceModule: "npm-b",
        },
        {
          originModule: "npm-b",
          replaceModule: "npm-c",
          context: /node_modules\/npm-a/,
        },
      ],
    }),
  ],
}

Options

rules[].context

Type: RegExp | (context: String) => booleans

context is RegExp or function, which used to determinate which modules should be modified.

RegExp will be applied to full module path (based on userRequest).

rule[].originModule

Type: String

The module before the replacement.

rule[]replaceModule

Type: String

The module after the replacement.

Readme

Keywords

Package Sidebar

Install

npm i webpack-plugin-replace-module

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

2.52 kB

Total Files

3

Last publish

Collaborators

  • kyrielin