{"id":14156025,"url":"https://github.com/unplugin/unplugin-replace","last_synced_at":"2025-06-21T03:10:01.780Z","repository":{"id":225525974,"uuid":"766209113","full_name":"unplugin/unplugin-replace","owner":"unplugin","description":"A universal bundler plugin which replaces targeted strings in files.","archived":false,"fork":false,"pushed_at":"2025-06-16T08:05:02.000Z","size":927,"stargazers_count":20,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-16T09:25:54.820Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jsr.io/@unplugin/replace","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unplugin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"sxzz"}},"created_at":"2024-03-02T16:26:33.000Z","updated_at":"2025-06-09T06:42:05.000Z","dependencies_parsed_at":"2024-04-01T05:39:40.984Z","dependency_job_id":"a8ab55ca-e63f-4565-9ee4-b454c2067b32","html_url":"https://github.com/unplugin/unplugin-replace","commit_stats":null,"previous_names":["unplugin/unplugin-replace"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/unplugin/unplugin-replace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unplugin%2Funplugin-replace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unplugin%2Funplugin-replace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unplugin%2Funplugin-replace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unplugin%2Funplugin-replace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unplugin","download_url":"https://codeload.github.com/unplugin/unplugin-replace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unplugin%2Funplugin-replace/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261055386,"owners_count":23103227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-17T08:05:09.856Z","updated_at":"2025-06-21T03:09:55.786Z","avatar_url":"https://github.com/unplugin.png","language":"TypeScript","readme":"# unplugin-replace [![npm](https://img.shields.io/npm/v/unplugin-replace.svg)](https://npmjs.com/package/unplugin-replace) [![JSR](https://jsr.io/badges/@unplugin/replace)](https://jsr.io/@unplugin/replace)\n\n[![Unit Test](https://github.com/unplugin/unplugin-replace/actions/workflows/unit-test.yml/badge.svg)](https://github.com/unplugin/unplugin-replace/actions/workflows/unit-test.yml)\n\n🍣 A universal bundler plugin which replaces targeted strings in files, based on [@rollup/plugin-replace](https://www.npmjs.com/package/@rollup/plugin-replace).\n\n## Installation\n\n```bash\n# npm\nnpm i -D unplugin-replace\n\n# jsr\nnpx jsr add -D @unplugin/replace\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eVite\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vite.config.ts\nimport Replace from 'unplugin-replace/vite'\n\nexport default defineConfig({\n  plugins: [Replace()],\n})\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRollup\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// rollup.config.js\nimport Replace from 'unplugin-replace/rollup'\n\nexport default {\n  plugins: [Replace()],\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eesbuild\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// esbuild.config.js\nimport { build } from 'esbuild'\n\nbuild({\n  plugins: [require('unplugin-replace/esbuild')()],\n})\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWebpack\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// webpack.config.js\nmodule.exports = {\n  /* ... */\n  plugins: [require('unplugin-replace/webpack')()],\n}\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n## Usage\n\n### Options\n\nFor all options please refer to [docs](https://github.com/rollup/plugins/tree/master/packages/replace#options).\n\nThis plugin accepts all [@rollup/plugin-replace](https://github.com/rollup/plugins/tree/master/packages/replace#options) options, and some extra options that are specific to this plugin.\n\n### `options.values`\n\n- Type: `{ [find: string]: Replacement } | ReplaceItem[]`\n- Default: `[]`\n\n```ts\ntype ReplaceItem = {\n  /** Supply a string or RegExp to find what you are looking for. */\n  find: string | RegExp\n\n  /**\n   * Can be a string or a function.\n   * - If it's a string, it will replace the substring matched by pattern. A number of special replacement patterns are supported\n   * - If it's a function, it will be invoked for every match and its return value is used as the replacement text.\n   */\n  replacement: Replacement\n}\ntype Replacement = string | ((id: string, match: RegExpExecArray) =\u003e string)\n```\n\nComparing with `@rollup/plugin-replace`, `find` option supports regex pattern.\n\n**Example:**\n\n```ts\nReplace({\n  values: [\n    {\n      find: /apples/gi,\n      replacement: 'oranges',\n    },\n    {\n      find: 'process.env.NODE_ENV',\n      replacement: '\"production\"',\n    },\n  ],\n})\n```\n\n## Sponsors\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg\"\u003e\n    \u003cimg src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## License\n\n[MIT](./LICENSE) License © 2024-PRESENT [三咲智子](https://github.com/sxzz)\n","funding_links":["https://github.com/sponsors/sxzz"],"categories":["others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funplugin%2Funplugin-replace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funplugin%2Funplugin-replace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funplugin%2Funplugin-replace/lists"}