replace-module-webpack-plugin

1.0.0 • Public • Published

replace-module-webpack-plugin

Webpack plugin for modifying imported modules.

Installation

NPM

npm i -D replace-module-webpack-plugin

YARN

yarn add -D replace-module-webpack-plugin

CJS

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

Usage

webpack.config.js
module.exports = {
  plugins: [
    new WebpackPluginReplaceNpm({
      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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i replace-module-webpack-plugin

      Weekly Downloads

      3

      Version

      1.0.0

      License

      MIT

      Unpacked Size

      3.23 kB

      Total Files

      4

      Last publish

      Collaborators

      • kyrielin