{"id":13656900,"url":"https://github.com/lukeed/webpack-plugin-replace","last_synced_at":"2025-10-09T18:24:57.325Z","repository":{"id":48068437,"uuid":"93282744","full_name":"lukeed/webpack-plugin-replace","owner":"lukeed","description":"Replace content while bundling.","archived":false,"fork":false,"pushed_at":"2021-08-09T08:02:20.000Z","size":14,"stargazers_count":36,"open_issues_count":7,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-10T10:39:06.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/lukeed.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-04T01:13:32.000Z","updated_at":"2023-08-10T22:57:41.000Z","dependencies_parsed_at":"2022-08-12T17:50:58.887Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/webpack-plugin-replace","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwebpack-plugin-replace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwebpack-plugin-replace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwebpack-plugin-replace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwebpack-plugin-replace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/webpack-plugin-replace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250539533,"owners_count":21447330,"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-02T05:00:34.129Z","updated_at":"2025-10-09T18:24:52.304Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# webpack-plugin-replace [![Build Status](https://travis-ci.org/lukeed/webpack-plugin-replace.svg?branch=master)](https://travis-ci.org/lukeed/webpack-plugin-replace)\n\n\u003e Replace content while bundling.\n\n\n## Install\n\n```\n$ npm install --save-dev webpack-plugin-replace\n```\n\n\n## Usage\n\n```js\n// webpack.config.js\nconst ReplacePlugin = require('webpack-plugin-replace');\n\nmodule.exports = {\n  // ...\n  plugins: [\n    new ReplacePlugin({\n      exclude: [\n        'foo.js',\n        /node_modules/,\n        filepath =\u003e filepath.includes('ignore')\n      ],\n      patterns: [{\n        regex: /throw\\s+(new\\s+)?(Type|Reference)?Error\\s*\\(/g,\n        value: 'return;('\n      }],\n      values: {\n        'process.env.NODE_ENV': JSON.stringify('production'),\n        'FOO_BAR': '\"hello world\"',\n        'DEV_MODE': false,\n      }\n    })\n  ]\n};\n```\n\n\n## API\n\n### webpack-plugin-replace(options)\n\n#### options.exclude\n\nType: `Array|String|Function|RegExp`\u003cbr\u003e\nDefault: `false`\n\nIf multiple conditions are provided, matching _any_ condition will exclude the filepath, which prevents any alterations.\n\n\u003e **Note:** By default, nothing is excluded!\n\n#### options.include\n\nType: `Array|String|Function|RegExp`\u003cbr\u003e\nDefault: `true`\n\nIf multiple conditions are provided, matching _any_ condition will include \u0026 scan the filepath for eligible replacements.\n\n\u003e **Note:** By default, all filepaths are included!\n\n#### options.patterns\n\nType: `Array`\u003cbr\u003e\nDefault: `[]`\n\nAn array of `RegExp` pattern definitions. Each definition is an object with `regex \u003cRegExp\u003e` and `value \u003cString|Function\u003e` keys. If `value` is a function, it takes the same arguments as [`String.prototype.relace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter).\n\n#### options.values\n\nType: `Object`\u003cbr\u003e\nDefault: `{}`\n\nAn object whose keys are `strings` that should be replaced and whose values are `strings` the replacements.\n\nIf desired, you may forgo the `values` key \u0026 declare your `key:value` pairs directly to the main configuration. For example:\n\n```js\n{\n  exclude: /node_modules/,\n  values: {\n    'process.env.NODE_ENV': JSON.stringify('production'),\n  }\n}\n\n// is the same as:\n\n{\n  exclude: /node_modules/,\n  'process.env.NODE_ENV': JSON.stringify('production'),\n}\n```\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fwebpack-plugin-replace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fwebpack-plugin-replace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fwebpack-plugin-replace/lists"}