
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
unplugin-replace
Advanced tools
🍣 A universal bundler plugin which replaces targeted strings in files, based on @rollup/plugin-replace.
# npm
npm i -D unplugin-replace
# jsr
npx jsr add -D @unplugin/replace
// vite.config.ts
import Replace from 'unplugin-replace/vite'
export default defineConfig({
plugins: [Replace()],
})
// rollup.config.js
import Replace from 'unplugin-replace/rollup'
export default {
plugins: [Replace()],
}
// esbuild.config.js
import { build } from 'esbuild'
build({
plugins: [require('unplugin-replace/esbuild')()],
})
// webpack.config.js
module.exports = {
/* ... */
plugins: [require('unplugin-replace/webpack')()],
}
For all options please refer to docs.
This plugin accepts all @rollup/plugin-replace options, and some extra options that are specific to this plugin.
options.values
{ [find: string]: Replacement } | ReplaceItem[]
[]
type ReplaceItem = {
/** Supply a string or RegExp to find what you are looking for. */
find: string | RegExp
/**
* Can be a string or a function.
* - If it's a string, it will replace the substring matched by pattern. A number of special replacement patterns are supported
* - If it's a function, it will be invoked for every match and its return value is used as the replacement text.
*/
replacement: Replacement
}
type Replacement = string | ((id: string, match: RegExpExecArray) => string)
Comparing with @rollup/plugin-replace
, find
option supports regex pattern.
Example:
Replace({
values: [
{
find: /apples/gi,
replacement: 'oranges',
},
{
find: 'process.env.NODE_ENV',
replacement: '"production"',
},
],
})
FAQs
A universal bundler plugin which replaces targeted strings in files.
The npm package unplugin-replace receives a total of 2,616 weekly downloads. As such, unplugin-replace popularity was classified as popular.
We found that unplugin-replace demonstrated a healthy version release cadence and project activity because the last version was released less than 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
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.