
Research
Malicious npm Package Brand-Squats TanStack to Exfiltrate Environment Variables
A brand-squatted TanStack npm package used postinstall scripts to steal .env files and exfiltrate developer secrets to an attacker-controlled endpoint.
replace-in-file-webpack-plugin
Advanced tools
A webpack plugin to replace strings in file(s) after building
This is a webpack plugin that can replace content in file(s) after compilation is done. This is useful when you want to replace content in any kind of files(html, css, js etc) which are not processed by loaders.
Install the plugin with npm:
$ npm install replace-in-file-webpack-plugin --save-dev
Add the plugin to your webpack and config as follows:
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
const webpackConfig = {
entry: 'index.js',
output: {
path: __dirname + '/dist',
filename: 'index_bundle.js'
},
plugins: [
new ReplaceInFileWebpackPlugin([{
dir: 'dist',
files: ['index.html', 'main.html'],
rules: [{
search: '@class',
replace: 'main-class'
},{
search: /@title/,
replace: 'webpack'
}]
}, {
dir: 'dist/style',
test: /\.html$/,
rules: [{
search: /version/ig,
replace: '1.0.0'
},{
search: '@title',
replace: function(match){
}
}]
},{
dir: 'dist/style',
test: [/\.css$/, /\.txt/],
rules: [{
search: /version/ig,
replace: '1.0.0'
},{
search: '@title',
replace: 'webpack'
}]
}])
]
};
You can pass an array of configuration options to ReplaceInFileWebpackPlugin. Each configuration has following items:
dir: Optional. Base dir to find the files, if not provided, use the root of webpack context.files: Optional. Files in dir to find for replacement.test: Optional. Regex expression or Regex expressions array to match files in dir.rules: Required. Replace content rules array. Each rule has search and replace properties.search: Required. String or Regex expression used for searching content in files.replace: Required. String or funcion used for replacing the searching content.This project is licensed under MIT.
FAQs
A webpack plugin to replace strings in file(s) after building
The npm package replace-in-file-webpack-plugin receives a total of 78,267 weekly downloads. As such, replace-in-file-webpack-plugin popularity was classified as popular.
We found that replace-in-file-webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
A brand-squatted TanStack npm package used postinstall scripts to steal .env files and exfiltrate developer secrets to an attacker-controlled endpoint.

Research
Compromised SAP CAP npm packages download and execute unverified binaries, creating urgent supply chain risk for affected developers and CI/CD environments.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.