Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/le0michine/webpack-string-replacer-plugin
Replaces strings in assets according to provided regex or string
https://github.com/le0michine/webpack-string-replacer-plugin
Last synced: 25 days ago
JSON representation
Replaces strings in assets according to provided regex or string
- Host: GitHub
- URL: https://github.com/le0michine/webpack-string-replacer-plugin
- Owner: Le0Michine
- Created: 2017-02-10T16:34:22.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-14T18:34:34.000Z (almost 8 years ago)
- Last Synced: 2024-11-30T10:46:49.039Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/webpack-string-replacer-plugin
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# webpack-string-replacer-plugin
A plugin for replacing string value in assets. It processes assets right before emitting so you can treat this plugin as a postprocessor.
Installation
```
npm install --save-dev webpack-string-replacer-plugin
```Usage
```javascript
const StringReplacerPlugin = require('webpack-string-replacer-plugin');...
// add to webpack plugins array
plugins: [
new StringReplacerPlugin(options)
]/*
options: {
assets: array of assets names to update, by default all the assets will be updated
replaceValue: regex or string to replace, this option is mandatory
newValue: new value to insert or function, by default is ''
}*/
```
PS. Under the hood it uses [String.prototype.replace()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) method with `replaceValue` and `newValue` as parameters.