Search and replace text strings in your GobbleJS workflow
First, you need to have gobble installed - see the gobble readme for details. Then,
npm i -D gobble-searchreplace
In your gobblefile.js
:
var gobble = require( 'gobble' );
module.exports = gobble( 'src' ).transform( 'searchreplace', {
// Search for all instances of "foo"...
search: 'foo',
// ... and replace them with "bar".
replace: 'bar'
});
The search
and replace
options behave exactly as the parameters for String.replace()
.
This means that the search
option can be a String
or a RegExp
, and the replace
option can be a String
or a Function
. Check the documentation for String.replace()
for details.
"THE BEER-WARE LICENSE":
<[email protected]> wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return.