regexp-replace-loader

1.0.1 • Public • Published

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".

Readme

Keywords

Package Sidebar

Install

npm i regexp-replace-loader

Weekly Downloads

1,332

Version

1.0.1

License

MIT

Last publish

Collaborators

  • em-user