{"_id":"@0xbigboss/vite-plugin-web-extension","_rev":"4-98ff30e5121172b5d9a1288d27e7036f","name":"@0xbigboss/vite-plugin-web-extension","dist-tags":{"latest":"5.4.0"},"versions":{"5.2.0":{"name":"@0xbigboss/vite-plugin-web-extension","version":"5.2.0","keywords":["vite","vite-plugin","web","extension","browser","chrome","firefox","edge","manifest","manifest V2","manifest V3"],"author":{"name":"Big Boss"},"license":"MIT","_id":"@0xbigboss/vite-plugin-web-extension@5.2.0","maintainers":[{"name":"0xbigboss","email":"0xbigboss@proton.me"}],"homepage":"https://github.com/0xBigBoss/vite-plugin-web-extension#readme","bugs":{"url":"https://github.com/0xBigBoss/vite-plugin-web-extension/issues"},"dist":{"shasum":"3af27fc917a627cdffac29aaa31201358943a251","tarball":"https://registry.npmjs.org/@0xbigboss/vite-plugin-web-extension/-/vite-plugin-web-extension-5.2.0.tgz","fileCount":11,"integrity":"sha512-aCwyAgRVpfEVZ+qF05+aHZavvr5RERlJHRf+Y9TrBLqbgd6YS+upAg6EyENDOxxyZzNVuPhmQFfFqftTGEkRRQ==","signatures":[{"sig":"MEUCIQDvLiJakzchvY8h9aCai4HgpFve2nVEosVFX9E9i+3VeAIgbhJ9Fphdz9CTH/T7RDSAzcrdQ/8hOpGaWaXYLXT1HSg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":104994},"main":"./dist/index.cjs","type":"module","types":"./types/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=16.0.0"},"exports":{".":{"types":"./types/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./client":{"types":"./client.d.ts","import":"./client.mjs","require":"./client.mjs"}},"gitHead":"531c2451212d409eec6fb746aad740736c379668","scripts":{"dev":"unbuild --stub","lint":"prettier --write --loglevel warn .","test":"vitest","build":"unbuild","prepare":"husky install","release":"standard-version --sign","test:run":"vitest run","lint:check":"prettier --check .","publish:npm":"npm publish --access public","prepublishOnly":"pnpm run build"},"_npmUser":{"name":"0xbigboss","email":"0xbigboss@proton.me"},"repository":{"url":"git+https://github.com/0xBigBoss/vite-plugin-web-extension.git","type":"git"},"_npmVersion":"11.4.2","description":"A vite plugin for generating cross browser platform, ES module based web extensions","directories":{},"lint-staged":{"*":["prettier --write --cache --ignore-unknown"]},"_nodeVersion":"24.4.0","dependencies":{"etag":"^1.8.1","vite":"^7.1.3","fs-extra":"^11.2.0","@types/etag":"^1.8.3","magic-string":"^0.30.5","@types/chrome":"^0.0.233","content-security-policy-parser":"^0.4.1"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.15.0","devDependencies":{"sass":"^1.70.0","husky":"^8.0.3","rollup":"^4.8.0","vitest":"^2.1.1","unbuild":"^2.0.0","prettier":"2.8.8","typescript":"^5.5.4","@types/node":"^20.19.0","lint-staged":"^15.2.0","@types/fs-extra":"^11.0.4","standard-version":"^9.5.0"},"peerDependencies":{"vite":"^5.0.0 || ^6.0.0 || ^7.0.0"},"standard-version":{"scripts":{"prerelease":"pnpm test:run && pnpm build"}},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-web-extension_5.2.0_1756102553878_0.8393021794994662","host":"s3://npm-registry-packages-npm-production"}},"5.2.1":{"name":"@0xbigboss/vite-plugin-web-extension","version":"5.2.1","keywords":["vite","vite-plugin","web","extension","browser","chrome","firefox","edge","manifest","manifest V2","manifest V3"],"author":{"name":"Big Boss"},"license":"MIT","_id":"@0xbigboss/vite-plugin-web-extension@5.2.1","maintainers":[{"name":"0xbigboss","email":"0xbigboss@proton.me"}],"homepage":"https://github.com/0xBigBoss/vite-plugin-web-extension#readme","bugs":{"url":"https://github.com/0xBigBoss/vite-plugin-web-extension/issues"},"dist":{"shasum":"37ef44e164117d569f91727f39f9da3217e14278","tarball":"https://registry.npmjs.org/@0xbigboss/vite-plugin-web-extension/-/vite-plugin-web-extension-5.2.1.tgz","fileCount":11,"integrity":"sha512-IqKCPF0lU1wvf08OAVSN9nzoadGpntm0IYMEHc2/3ZGhMzRWrFbHp60npJcpWNvXBWsz3yl5rdpMpdpXWCJHXA==","signatures":[{"sig":"MEUCIBIGIKLNvTTah+UmeEzd+CyDita4nZ780BId+ovnwGKxAiEA6k25VqqSRrf1ijtIZdsmNptXJ2wnY5b2FyYbHE32GGU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":105009},"main":"./dist/index.cjs","type":"module","_from":"file:0xbigboss-vite-plugin-web-extension-5.2.1.tgz","types":"./types/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=16.0.0"},"exports":{".":{"types":"./types/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./client":{"types":"./client.d.ts","import":"./client.mjs","require":"./client.mjs"}},"scripts":{"dev":"unbuild --stub","lint":"prettier --write --loglevel warn .","test":"vitest","build":"unbuild","release":"standard-version --sign","test:run":"vitest run","lint:check":"prettier --check .","publish:npm":"npm publish"},"_npmUser":{"name":"0xbigboss","email":"0xbigboss@proton.me"},"_resolved":"/private/var/folders/9b/khhz0hwd07z_p9n1wh5mqg_80000gn/T/40f73c1462eeaba8141fb4fe19b16d70/0xbigboss-vite-plugin-web-extension-5.2.1.tgz","_integrity":"sha512-IqKCPF0lU1wvf08OAVSN9nzoadGpntm0IYMEHc2/3ZGhMzRWrFbHp60npJcpWNvXBWsz3yl5rdpMpdpXWCJHXA==","repository":{"url":"git+https://github.com/0xBigBoss/vite-plugin-web-extension.git","type":"git"},"_npmVersion":"11.4.2","description":"A vite plugin for generating cross browser platform, ES module based web extensions","directories":{},"lint-staged":{"*":["prettier --write --cache --ignore-unknown"]},"_nodeVersion":"24.4.0","dependencies":{"etag":"^1.8.1","vite":"^7.1.3","fs-extra":"^11.2.0","@types/etag":"^1.8.3","magic-string":"^0.30.5","@types/chrome":"^0.0.233","content-security-policy-parser":"^0.4.1"},"_hasShrinkwrap":false,"devDependencies":{"sass":"^1.70.0","husky":"^8.0.3","rollup":"^4.8.0","vitest":"^2.1.1","unbuild":"^2.0.0","prettier":"2.8.8","typescript":"^5.5.4","@types/node":"^20.19.0","lint-staged":"^15.2.0","@types/fs-extra":"^11.0.4","standard-version":"^9.5.0"},"peerDependencies":{"vite":"^5.0.0 || ^6.0.0 || ^7.0.0"},"standard-version":{"scripts":{"prerelease":"pnpm test:run && pnpm build"}},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-web-extension_5.2.1_1756145125740_0.2925899271315586","host":"s3://npm-registry-packages-npm-production"}},"5.4.0":{"name":"@0xbigboss/vite-plugin-web-extension","version":"5.4.0","keywords":["vite","vite-plugin","web","extension","browser","chrome","firefox","edge","manifest","manifest V2","manifest V3"],"author":{"name":"Big Boss"},"license":"MIT","_id":"@0xbigboss/vite-plugin-web-extension@5.4.0","maintainers":[{"name":"0xbigboss","email":"0xbigboss@proton.me"}],"homepage":"https://github.com/0xBigBoss/vite-plugin-web-extension#readme","bugs":{"url":"https://github.com/0xBigBoss/vite-plugin-web-extension/issues"},"dist":{"shasum":"45226ef3694dc1ee87c2af00550acc4478612d12","tarball":"https://registry.npmjs.org/@0xbigboss/vite-plugin-web-extension/-/vite-plugin-web-extension-5.4.0.tgz","fileCount":11,"integrity":"sha512-DgbgVGzrQ0EHyfovJv6QtCf56F36wpaGNV8MKEx0NB7H0cAa/kWdvl0sLItCYzguXXJYBSJjjqLnjAxcd7Nv7A==","signatures":[{"sig":"MEUCIFVq1WGd1kUYRmjFX8SpB5sl8cxBBNOlvkravqVFl6PKAiEAu2KPp0HtghgYmHcbVBqaG8ogo2LRAeWv3jeAoIItPIE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":105098},"main":"./dist/index.cjs","type":"module","types":"./types/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=16.0.0"},"exports":{".":{"types":"./types/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./client":{"types":"./client.d.ts","import":"./client.mjs","require":"./client.mjs"}},"gitHead":"cfe8e1ef45e91a662639147b64e28df8d14044b5","scripts":{"dev":"unbuild --stub","lint":"prettier --write --loglevel warn .","test":"vitest","build":"unbuild","prepare":"husky install","release":"standard-version --sign","test:run":"vitest run","lint:check":"prettier --check .","publish:npm":"npm publish","prepublishOnly":"pnpm run build"},"_npmUser":{"name":"0xbigboss","email":"0xbigboss@proton.me"},"repository":{"url":"git+https://github.com/0xBigBoss/vite-plugin-web-extension.git","type":"git"},"_npmVersion":"11.4.2","description":"A vite plugin for generating cross browser platform, ES module based web extensions","directories":{},"lint-staged":{"*":["prettier --write --cache --ignore-unknown"]},"_nodeVersion":"24.4.0","dependencies":{"etag":"^1.8.1","fs-extra":"^11.2.0","@types/etag":"^1.8.3","magic-string":"^0.30.5","@types/chrome":"^0.0.233","content-security-policy-parser":"^0.4.1"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.15.0","devDependencies":{"sass":"^1.70.0","vite":"^7.1.3","husky":"^8.0.3","rollup":"^4.8.0","vitest":"^2.1.1","unbuild":"^2.0.0","prettier":"2.8.8","typescript":"^5.5.4","@types/node":"^20.19.0","lint-staged":"^15.2.0","@types/fs-extra":"^11.0.4","standard-version":"^9.5.0"},"peerDependencies":{"vite":"^7.0.0"},"standard-version":{"scripts":{"prerelease":"pnpm test:run && pnpm build"}},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-web-extension_5.4.0_1756150112508_0.05342408590955716","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-08-25T06:15:53.711Z","modified":"2026-06-24T17:39:22.407Z","5.2.0":"2025-08-25T06:15:54.051Z","5.2.1":"2025-08-25T18:05:25.930Z","5.4.0":"2025-08-25T19:28:32.689Z"},"bugs":{"url":"https://github.com/0xBigBoss/vite-plugin-web-extension/issues"},"author":{"name":"Big Boss"},"license":"MIT","homepage":"https://github.com/0xBigBoss/vite-plugin-web-extension#readme","keywords":["vite","vite-plugin","web","extension","browser","chrome","firefox","edge","manifest","manifest V2","manifest V3"],"repository":{"url":"git+https://github.com/0xBigBoss/vite-plugin-web-extension.git","type":"git"},"description":"A vite plugin for generating cross browser platform, ES module based web extensions","maintainers":[{"email":"0xbigboss@proton.me","name":"alleneubank"}],"readme":"# vite-plugin-web-extension-vite7\n\n[![npm version](https://img.shields.io/npm/v/vite-plugin-web-extension-vite7)](https://www.npmjs.com/package/vite-plugin-web-extension-vite7)\n[![node compatibility](https://img.shields.io/node/v/vite-plugin-web-extension-vite7)](https://nodejs.org/en/about/releases/)\n[![ci](https://github.com/0xBigBoss/vite-plugin-web-extension/actions/workflows/ci.yml/badge.svg)](https://github.com/0xBigBoss/vite-plugin-web-extension/actions/workflows/ci.yml)\n\n> Generate cross browser platform, ES module based web extensions.\n\n**✨ This fork includes Vite 7.1.3 support with modernized dependencies and improved TypeScript handling.**\n\nBased on the original work by [@samrum](https://github.com/samrum/vite-plugin-web-extension).\n\n- Manifest V2 & V3 Support\n- Completely ES module based extensions\n  - Including in content scripts!\n- Vite based html and static asset handling\n  - Including in content scripts!\n- HMR support\n  - All Manifest entry points\n    - Including content scripts when using a Chromium browser!\n  - CSS styles in content scripts\n    - Including shadow DOM rendered content!\n  - Including Manifest V3 support since Chromium 110!\n\n## Quick Start\n\nCreate a new Vite web extension project\n\n```sh\nnpm init @samrum/vite-plugin-web-extension@latest\n```\n\nSupports choice of Manifest version, TypeScript support, and framework (Preact, React, Solid, Svelte, Vanilla, Vue).\n\nCheck the README of the generated extension for usage information.\n\n## Usage\n\nRequires Vite 3+\n\n```sh\nnpm install vite-plugin-web-extension-vite7\n```\n\n### Examples\n\n<details>\n  <summary>Manifest V2</summary>\n\nvite.config.js:\n\n```js\nimport { defineConfig } from \"vite\";\nimport webExtension from \"vite-plugin-web-extension-vite7\";\n\nexport default defineConfig({\n  plugins: [\n    webExtension({\n      manifest: {\n        name: pkg.name,\n        description: pkg.description,\n        version: pkg.version,\n        manifest_version: 2,\n        background: {\n          scripts: [\"src/background/script.js\"],\n        },\n      },\n    }),\n  ],\n});\n```\n\n</details>\n\n<details>\n  <summary>Manifest V3</summary>\n\nvite.config.js:\n\n```js\nimport { defineConfig } from \"vite\";\nimport webExtension from \"vite-plugin-web-extension-vite7\";\n\nexport default defineConfig({\n  plugins: [\n    webExtension({\n      manifest: {\n        name: pkg.name,\n        description: pkg.description,\n        version: pkg.version,\n        manifest_version: 3,\n        background: {\n          service_worker: \"src/background/serviceWorker.js\",\n        },\n      },\n    }),\n  ],\n});\n```\n\n</details>\n\n<details>\n  <summary>Firefox Experimental Manifest V3 </summary>\n  There are two configurations an extension needs to make for experimental manifest V3 support:\n  \n  1. Background service workers are not supported, so you are required to use a background script.\n  2. The `use_dynamic_url` property is not supported for web accessible resources. In the plugin options, set `useDynamicUrlWebAccessibleResources` to false:\n\n      ```js\n        webExtension({\n          ...\n          useDynamicUrlWebAccessibleResources: false,\n        }),\n      ```\n\n</details>\n\n<details>\n  <summary>Devtools</summary>\n  To add content to the browser dev tools, add `devtools_page` to your manifest\n\n```js\ndevtools_page: \"src/entries/devtools/index.html\",\n```\n\nPlace a script `devtools.js` in `public` dir.\n\n```js\nvar _browser;\nif (chrome) {\n  _browser = chrome;\n} else {\n  _browser = browser;\n}\n_browser.devtools.panels.create(\n  \"My Panel\", // title\n  \"images/icon-16.png\", // icon\n  \"src/entries/devtools/index.html\" // content\n);\n```\n\nThen load the script from your devtools html which placed in `src/entries/devtools/index.html`.\n\n```html\n<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <title>Devtools</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n    <script type=\"module\" src=\"./main.ts\"></script>\n    <script src=\"/devtools.js\"></script>\n  </body>\n</html>\n```\n\n</details>\n\n### Options\n\nmanifest\n\n- The [manifest](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) definition for your extension\n- All manifest property file names should be relative to the root of the project.\n\nuseDynamicUrlWebAccessibleResources (optional)\n\n- Type: `boolean`\n- Default: `false`\n- Adds the `use_dynamic_url` property to web accessible resources generated by the plugin\n  - Caution: In Chrome 130, with this option enabled, importing a generated resource using `chrome.runtime.getURL` will not work ([Chromium Issue](https://issues.chromium.org/issues/363027634))l\n\noptimizeWebAccessibleResources (optional)\n\n- Type: `boolean`\n- Default: `true`\n- On build, in Manifest V3, merge web accessible resource definitions that have matching non-`resource` properties and dedupe and sort `resources`. In Manifest V2, sort web accessible resources.\n\nadditionalInputs (optional)\n\n- Type:\n\n  ```ts\n    type AdditionalInput =\n      | string\n      | {\n          fileName: string;\n          webAccessible?:\n            | boolean\n            | {\n                matches: string[];\n                extensionIds?: string[];\n                excludeEntryFile?: boolean;\n              }\n            | {\n                matches?: string[];\n                extensionIds: string[];\n                excludeEntryFile?: boolean;\n              };\n        };\n\n    additionalInputs?: {\n      scripts?: AdditionalInput[];\n      html?: AdditionalInput[];\n      styles?: AdditionalInput[];\n    };\n  ```\n\n- Additional input files that should be processed and treated as web extension inputs.\n- Useful for dynamically injected scripts or dynamically opened HTML pages.\n- The webAccessible option configures whether the input file and its dependencies are included in the manifest `web_accessible_resources` property. Defaults to true.\n  - When set to `true`, defaults to:\n    ```ts\n      {\n        matches: ['<all_urls>'],\n        excludeEntryFile: false,\n      }\n    ```\n  - The `excludeEntryFile` option prevents the entry file from being added as a web accessible resource. Defaults to false.\n- Example\n  ```ts\n    webExtension({\n      manifest: ...,\n      additionalInputs: {\n        scripts: [\n          'src/entries/webAccessibleScript.js', // defaults to webAccessible: true\n          {\n            fileName: 'src/entries/webAccessibleScript2.js',\n            webAccessible: true,\n          },\n          {\n            fileName: 'src/entries/privateScript.js', // entry file and dependencies are not web accessible\n            webAccessible: false,\n          },\n          {\n            fileName: 'src/entries/entryFileExcluded.js', // entry file is not web accessible and dependencies are\n            webAccessible: {\n              matches: ['<all_urls>'],\n              excludeEntryFile: true,\n            },\n          },\n        ],\n      },\n    })\n  ```\n\n### Content Scripts\n\n- For HMR style support within shadow DOMs, use the `addStyleTarget` function to add the shadowRoot of your element as a style target:\n\n  ```js\n  if (import.meta.hot) {\n    const { addViteStyleTarget } = await import(\n      \"vite-plugin-web-extension-vite7/client\"\n    );\n\n    await addViteStyleTarget(appContainer);\n  }\n  ```\n\n- For builds, use the `import.meta.PLUGIN_WEB_EXT_CHUNK_CSS_PATHS` variable to reference an array of CSS asset paths associated with the current output chunk.\n\n### TypeScript\n\nIn an [env.d.ts file](https://vitejs.dev/guide/env-and-mode.html#intellisense-for-typescript), add the following type reference to define the plugin specific `import.meta` variables as well as plugin client functions:\n\n```ts\n/// <reference types=\"vite-plugin-web-extension-vite7/client\" />\n```\n\n### Browser Support\n\nThe following requirements must be met by the browser:\n\n- Must support dynamic module imports made by web extension content scripts.\n- Must support `import.meta.url`\n\nA sample of supported browsers:\n\n|          | Manifest V2 | Manifest V3                                                                            |\n| -------- | ----------- | -------------------------------------------------------------------------------------- |\n| Chromium | 64          | 91                                                                                     |\n| Firefox  | 89          | N/A ([In development](https://blog.mozilla.org/addons/2021/05/27/manifest-v3-update/)) |\n\nThe plugin will automatically default vite's `build.target` config option to these minimum browser versions if not already defined by the user.\n\nFor dev mode support in Manifest V3, Chromium version must be at least 110.\n\n## How it works\n\nThe plugin will take the provided manifest, generate rollup input scripts for supported manifest properties, then output an ES module based web extension.\n\nThis includes:\n\n- Generating and using a dynamic import wrapper script in place of original content scripts. Then, moving the original scripts to `web_accessible_resources` so they are accessible by the wrapper script. Needed because content scripts are not able to be loaded directly as ES modules.\n  - This may expose your extension to fingerprinting by other extensions or websites. Manifest V3 supports a [`use_dynamic_url` property](https://developer.chrome.com/docs/extensions/mv3/manifest/web_accessible_resources/#:~:text=access%20the%20resources.-,use_dynamic_url,-If%20true%2C%20only) that will mitigate this. This option is set for manifest V3 web accessible resources generated by this plugin.\n- Modifying Vite's static asset handling to maintain `import.meta.url` usages instead of rewriting to `self.location`. Needed so content script static asset handling can function correctly.\n- Modifying Vite's HMR client to add support for targeting specific elements as style injection locations. Needed to support HMR styles in shadow DOM rendered content.\n\n### Why this is a Vite specific plugin\n\nThe plugin relies on Vite to parse and handle html files in addition to relying on Vite's manifest generation in order to map generated files to the eventual extension manifest.\n\n## Development\n\nThis project uses [pnpm](https://pnpm.io/) for package management.\n\n### Lint\n\n```sh\npnpm lint\n```\n\n### Tests\n\n```sh\npnpm test\n```\n\n### Build\n\n```sh\npnpm build\n```\n","readmeFilename":"README.md"}