regexp-replace-loader
v1.0.1
Published
A webpack loader to replace a regexp pattern with a string
Downloads
5,959
Readme
regexp-replace-loader
A webpack loader to replace a regexp pattern with a string
Installation
npm install regexp-replace-loader
Usage
webpack 2.x
// webpack.config.js
...
module: {
rules: [
{
test: /\.js$/,
loader: 'regexp-replace-loader',
options: {
match: {
pattern: 'ba(r|z)',
flags: 'g'
},
replaceWith: 'foo'
}
}
]
}
webpack 1.x
// webpack.config.js
...
module: {
loaders: [
{
test: /\.js$/,
loader: 'regexp-replace-loader',
query: {
match: {
pattern: 'ba(r|z)',
flags: 'g'
},
replaceWith: 'foo'
}
}
]
}
All instances of "bar" and "baz" will then be replaced by "foo".