Gathering detailed insights and metrics for gulp-replace
Gathering detailed insights and metrics for gulp-replace
Gathering detailed insights and metrics for gulp-replace
Gathering detailed insights and metrics for gulp-replace
replace-ext
Replaces a file extension with another one.
gulp-rev-replace
Rewrite occurences of filenames which have been renamed by gulp-rev
gulp-batch-replace
A batch string/regexp replace plugin for gulp
gulp-replace-src
Rewrite occurences of filenames which have been renamed by gulp-rev
npm install gulp-replace
Typescript
Module System
Min. Node Version
Node Version
NPM Version
97.6
Supply Chain
99.4
Quality
74.7
Maintenance
100
Vulnerability
100
License
JavaScript (98.51%)
HTML (1.49%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
497 Stars
97 Commits
88 Forks
13 Watchers
9 Branches
22 Contributors
Updated on Apr 25, 2025
Latest Version
1.1.4
Package Id
gulp-replace@1.1.4
Unpacked Size
14.74 kB
Size
3.85 kB
File Count
6
NPM Version
8.19.2
Node Version
16.18.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
7
A string replace plugin for gulp
First, install gulp-replace
as a development dependency:
1npm install --save-dev gulp-replace 2# or 3yarn add --dev gulp-replace
Then, add it to your gulpfile.js
:
1const replace = require('gulp-replace'); 2const { src, dest } = require('gulp'); 3 4function replaceTemplate() { 5 return src(['file.txt']) 6 .pipe(replace('bar', 'foo')) 7 .pipe(dest('build/')); 8}; 9 10// or replace multiple strings 11function replaceTemplate() { 12 return src(['file.txt']) 13 .pipe(replace('bar', 'foo')) 14 .pipe(replace('baz', 'fuz')) 15 .pipe(dest('build/')); 16}; 17 18exports.replaceTemplate = replaceTemplate;
1const replace = require('gulp-replace'); 2const { src, dest } = require('gulp'); 3 4function replaceTemplate() { 5 return src(['file.txt']) 6 // See https://mdn.io/string.replace#Specifying_a_string_as_a_parameter 7 .pipe(replace(/foo(.{3})/g, '$1foo')) 8 .pipe(dest('build/')); 9}; 10 11exports.replaceTemplate = replaceTemplate;
1const replace = require('gulp-replace'); 2const { src, dest } = require('gulp'); 3 4function replaceTemplate() { 5 return src(['file.txt']) 6 .pipe(replace('foo', function handleReplace(match){ return match.reverse(); }) 7 .pipe(dest('build/')) 8}; 9 10exports.replaceTemplate = replaceTemplate;
1const replace = require('gulp-replace'); 2const { src, dest } = require('gulp'); 3 4function replaceTemplate() { 5 return src(['file.txt']) 6 .pipe(replace(/foo(.{3})/g, function handleReplace(match, p1, offset, string) { 7 // Replace foobaz with barbaz and log a ton of information 8 // See https://mdn.io/string.replace#Specifying_a_function_as_a_parameter 9 console.log('Found ' + match + ' with param ' + p1 + ' at ' + offset + ' inside of ' + string); 10 return 'bar' + p1; 11 })) 12 .pipe(dest('build/')); 13}; 14 15exports.replaceTemplate = replaceTemplate;
1const replace = require('gulp-replace'); 2const { src, dest } = require('gulp'); 3 4function replaceTemplate() { 5 return src(['file.txt']) 6 .pipe(replace('filename', function handleReplace() { 7 // Replaces instances of "filename" with "file.txt" 8 // this.file is also available for regex replace 9 // See https://github.com/gulpjs/vinyl#instance-properties for details on available properties 10 return this.file.relative; 11 })) 12 .pipe(dest('build/')); 13}; 14 15exports.replaceTemplate = replaceTemplate;
gulp-replace
can be called with a string or regex.
CAUTION:
replacement
could NOT be arrow function, because arrow function could not bindthis
Type: String
The string to search for.
Type: String
or Function
The replacement string or function. If replacement
is a function, it will be called once for each match and will be passed the string that is to be replaced.
The value of this.file
will be equal to the vinyl instance for the file being processed.
Type: RegExp
The regex pattern to search for. See the MDN documentation for RegExp for details.
Type: String
or Function
The replacement string or function. See the MDN documentation for String.replace for details on special replacement string patterns and arguments to the replacement function.
The value of this.file
will be equal to the vinyl instance for the file being processed.
An optional third argument, options
, can be passed.
Type: Object
Type: boolean
Default: true
Skip binary files. This option is true
by default. If you want to replace content in binary files, you must explicitly set it to false
.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 10/27 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More