1.0.0 • Published 2 years ago
replace-module-webpack-plugin v1.0.0
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.
1.0.0
2 years ago