Webpack plugin for modifying imported modules.
npm i -D replace-module-webpack-plugin
yarn add -D replace-module-webpack-plugin
const WebpackPluginReplaceNpm = require("replace-module-webpack-plugin");
module.exports = {
plugins: [
new WebpackPluginReplaceNpm({
rules: [
{
originModule: "npm-a",
replaceModule: "npm-b",
},
{
originModule: "npm-b",
replaceModule: "npm-c",
context: /node_modules\/npm-a/,
},
],
}),
],
}
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
).
Type: String
The module before the replacement.
Type: String
The module after the replacement.