{"_id":"@namecheap/webpack-inject-plugin","_rev":"1-1d8fef51fc9f4a9261586b0a1f611388","name":"@namecheap/webpack-inject-plugin","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.0":{"name":"@namecheap/webpack-inject-plugin","version":"2.0.0","keywords":["webpack","plugin","loader","inject"],"author":{"name":"Namecheap"},"license":"MIT","_id":"@namecheap/webpack-inject-plugin@2.0.0","maintainers":[{"name":"blackrabbit99","email":"myzlio@gmail.com"},{"name":"namecheap_npm","email":"architects-npm@namecheap.com"}],"homepage":"https://github.com/namecheap/webpack-inject-plugin#readme","bugs":{"url":"https://github.com/namecheap/webpack-inject-plugin/issues"},"dist":{"shasum":"244a86c67d3f7b6d38ccb2184deb8afc7f87c61e","tarball":"https://registry.npmjs.org/@namecheap/webpack-inject-plugin/-/webpack-inject-plugin-2.0.0.tgz","fileCount":7,"integrity":"sha512-9eaPwSPcWOK06wPhrLiSUrmWHn1N7IfVkgruQRqCtk5wy8/uPCqng1YxsrXkAtfcl8ZkXNpuZpmbKZd+OqZbIw==","signatures":[{"sig":"MEQCIGRKD/AgBRtXlgPXkm+q5k2jTcDCTQ4NfeiqrN1VzpKgAiAIhqNIPzwrnX+fhLGeG2p9JbOdlY/BbhHZ45tERXPUVQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21921},"main":"dist/main.js","gitHead":"a5192ad254545dc63c6927882c907df5624ab590","scripts":{"lint":"eslint ./src","test":"jest","build":"tsc","prepare":"husky","test:watch":"npm run test -- --watch","build:watch":"tsc --watch","test:example":"cd example && webpack && npm run test:example:first && npm run test:example:second","test:example:first":"cd example && cat dist/main.js | grep \"console.log('hello world')\"","test:example:second":"cd example && cat dist/main.js | grep \"console.log('second injected code')\""},"_npmUser":{"name":"namecheap_npm","email":"architects-npm@namecheap.com"},"overrides":{"conventional-changelog-conventionalcommits":">= 8.0.0"},"repository":{"url":"git+https://github.com/namecheap/webpack-inject-plugin.git","type":"git"},"_npmVersion":"10.9.2","description":"A webpack plugin to dynamically inject code into the bundle.","directories":{},"_nodeVersion":"20.18.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.5.0","jest":"^29.7.0","husky":"^9.1.7","sinon":"^19.0.2","eslint":"^9.18.0","globals":"^15.14.0","ts-jest":"^29.2.5","webpack":"^5.97.1","prettier":"^3.4.2","@eslint/js":"^9.18.0","commitlint":"^19.6.1","typescript":"^5.7.3","@types/chai":"^4.3.20","@types/jest":"^29.5.14","lint-staged":"^15.4.2","webpack-cli":"^6.0.1","@types/sinon":"^17.0.3","@types/webpack":"^5.28.5","@eslint/eslintrc":"^3.2.0","eslint-config-xo":"0.46.0","semantic-release":"^24.2.1","eslint-config-prettier":"10.0.1","eslint-plugin-prettier":"^5.2.3","@typescript-eslint/parser":"8.21.0","@commitlint/config-conventional":"^19.6.0","@typescript-eslint/eslint-plugin":"^8.21.0","eslint-plugin-no-explicit-type-exports":"0.12.1"},"peerDependencies":{"webpack":">=5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/webpack-inject-plugin_2.0.0_1737734650032_0.5068672161329675","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@namecheap/webpack-inject-plugin","version":"2.0.1","description":"A webpack plugin to dynamically inject code into the bundle.","main":"dist/main.js","scripts":{"build":"tsc","build:watch":"tsc --watch","lint":"eslint ./src","test":"jest","test:example":"cd example && webpack && npm run test:example:first && npm run test:example:second","test:example:first":"cd example && cat dist/main.js | grep \"console.log('hello world')\"","test:example:second":"cd example && cat dist/main.js | grep \"console.log('second injected code')\"","test:watch":"npm run test -- --watch","prepare":"husky"},"repository":{"type":"git","url":"git+https://github.com/namecheap/webpack-inject-plugin.git"},"keywords":["webpack","plugin","loader","inject"],"author":{"name":"Namecheap"},"license":"MIT","bugs":{"url":"https://github.com/namecheap/webpack-inject-plugin/issues"},"publishConfig":{"access":"public"},"homepage":"https://github.com/namecheap/webpack-inject-plugin#readme","peerDependencies":{"webpack":">=5.0.0"},"devDependencies":{"@commitlint/config-conventional":"^19.6.0","@eslint/eslintrc":"^3.2.0","@eslint/js":"^9.18.0","@types/chai":"^4.3.20","@types/jest":"^29.5.14","@types/sinon":"^17.0.3","@types/webpack":"^5.28.5","@typescript-eslint/eslint-plugin":"^8.21.0","@typescript-eslint/parser":"8.21.0","chai":"^4.5.0","commitlint":"^19.6.1","eslint":"^9.18.0","eslint-config-prettier":"10.0.1","eslint-config-xo":"0.46.0","eslint-plugin-no-explicit-type-exports":"0.12.1","eslint-plugin-prettier":"^5.2.3","globals":"^15.14.0","husky":"^9.1.7","jest":"^29.7.0","lint-staged":"^15.4.2","prettier":"^3.4.2","semantic-release":"^24.2.1","sinon":"^19.0.2","ts-jest":"^29.2.5","typescript":"^5.7.3","webpack":"^5.97.1","webpack-cli":"^6.0.1"},"overrides":{"conventional-changelog-conventionalcommits":">= 8.0.0"},"_id":"@namecheap/webpack-inject-plugin@2.0.1","gitHead":"39286b109aa5ec7d9772637056918bca59512508","types":"./dist/main.d.ts","_nodeVersion":"20.18.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-vlDrtlOzfvoKcRQOQloYVUFtp4lV8GdBbKoC9p7MqihLkkD3qt8chzfy+WhYT8zrxzaXBKIhwBkSON0Z+KmF3Q==","shasum":"7b75ce780cac18968ff662beb4f99a3f2a139ed0","tarball":"https://registry.npmjs.org/@namecheap/webpack-inject-plugin/-/webpack-inject-plugin-2.0.1.tgz","fileCount":22,"unpackedSize":70518,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFRyxi6YVGgERJDuGuZhVA8cTt6dPiq00cjxvEvydTB2AiEA05tCydwZfZbiMIpHL0i8662O9triBoUBrq8nRiqqcH4="}]},"_npmUser":{"name":"namecheap_npm","email":"architects-npm@namecheap.com"},"directories":{},"maintainers":[{"name":"blackrabbit99","email":"myzlio@gmail.com"},{"name":"namecheap_npm","email":"architects-npm@namecheap.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/webpack-inject-plugin_2.0.1_1737738260445_0.6014191806099365"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-24T16:04:09.945Z","modified":"2025-01-24T17:04:20.970Z","2.0.0":"2025-01-24T16:04:10.211Z","2.0.1":"2025-01-24T17:04:20.729Z"},"bugs":{"url":"https://github.com/namecheap/webpack-inject-plugin/issues"},"author":{"name":"Namecheap"},"license":"MIT","homepage":"https://github.com/namecheap/webpack-inject-plugin#readme","keywords":["webpack","plugin","loader","inject"],"repository":{"type":"git","url":"git+https://github.com/namecheap/webpack-inject-plugin.git"},"description":"A webpack plugin to dynamically inject code into the bundle.","maintainers":[{"name":"blackrabbit99","email":"myzlio@gmail.com"},{"name":"namecheap_npm","email":"architects-npm@namecheap.com"}],"readme":"# webpack-inject-plugin\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors)\n[![CircleCI](https://circleci.com/gh/adierkens/webpack-inject-plugin/tree/master.svg?style=svg)](https://circleci.com/gh/adierkens/webpack-inject-plugin/tree/master) [![npm version](https://badge.fury.io/js/webpack-inject-plugin.svg)](https://badge.fury.io/js/webpack-inject-plugin) [![npm](https://img.shields.io/npm/dt/webpack-inject-plugin.svg)](https://www.npmjs.com/package/webpack-inject-plugin) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![codecov](https://codecov.io/gh/adierkens/webpack-inject-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/adierkens/webpack-inject-plugin)\n\nA webpack plugin to dynamically inject code into the bundle.\n\nYou can check out an example [here](./example)\n\n## Usage\n\n```javascript\n# webpack.config.js\n\nconst InjectPlugin = require('webpack-inject-plugin').default;\n\n\nmodule.exports = {\n    // Other stuff in your webpack config\n\n    plugins: [\n        new InjectPlugin(function() {\n            return \"console.log('Hello World');\"\n        });\n    ]\n};\n```\n\nThis webpack plugin accepts a single argument, a function to which returns the code to inject into the bundle.\n\nThe function is called using the same context as the loader, so everything [here](https://webpack.js.org/api/loaders/#the-loader-context) applies.\n\nYou can either return the raw content to load, or a `Promise` which resolves to the content, if you wish to be async.\n\n\n### options\n\nYou can also pass in more options:\n\n```javascript\nimport InjectPlugin, { ENTRY_ORDER } from 'webpack-inject-plugin';\n\nnew InjectPlugin(loader, {\n    entryName: 'entry name',         //  Limit the injected code to only the entry w/ this name\n    entryOrder: ENTRY_ORDER.First    //  Make the injected code be the first entry point\n                ENTRY_ORDER.Last     //  Make the injected code be the last entry point\n                ENTRY_ORDER.NotLast  //  Make the injected code be second to last. (The last entry module is the API of the bundle. Useful when you don't want to override that.) This is the default.\n});\n```\n\n### options.entryName\n\n> `string` | `function`\n\nA filter for which entries to inject code into.\nIf a `string`, only an entry with the same name will be used.\nIf a `function`, it will be called with each entry name -- and only inject code for each _truthy_ response\n\nex.\n\n```javascript\nnew InjectPlugin(loader, {\n  // This will inject code into every entry that's not named `foo`\n  entryName: key => key !== 'foo'\n});\n```\n\n### options.loaderID\n\n> `string`\n\nAn optional uniquie ID for the injected loader. If omitted, one will automatically be generated for you. \n\n## Additional Use Cases\n\nThough this could be used as a standalone plugin, you could also use it to create other webpack plugins, such as injecting code into the build based on a config file.\n\nExample:\n\n```javascript\nimport InjectPlugin from 'webpack-inject-plugin';\n\nfunction customLoader(options) {\n  return () => {\n    return \"console.log('My custom code generated from `options`');\";\n  };\n}\n\nexport default class MyPlugin {\n  constructor(options) {\n    this.options = options;\n  }\n\n  apply(compiler) {\n    new InjectPlugin(customLoader(this.options)).apply(compiler);\n  }\n}\n```\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore -->\n| [<img src=\"https://avatars1.githubusercontent.com/u/13004162?v=4\" width=\"100px;\" alt=\"Adam Dierkens\"/><br /><sub><b>Adam Dierkens</b></sub>](https://adamdierkens.com)<br />[💻](https://github.com/adierkens/webpack-inject-plugin/commits?author=adierkens \"Code\") | [<img src=\"https://avatars1.githubusercontent.com/u/1654019?v=4\" width=\"100px;\" alt=\"YellowKirby\"/><br /><sub><b>YellowKirby</b></sub>](https://github.com/YellowKirby)<br />[💻](https://github.com/adierkens/webpack-inject-plugin/commits?author=YellowKirby \"Code\") | [<img src=\"https://avatars2.githubusercontent.com/u/5383506?v=4\" width=\"100px;\" alt=\"Chvin\"/><br /><sub><b>Chvin</b></sub>](https://github.com/chvin)<br />[💻](https://github.com/adierkens/webpack-inject-plugin/commits?author=chvin \"Code\") |\n| :---: | :---: | :---: |\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!\n","readmeFilename":"README.md"}