[crx:web-accessible-resources] Error: Content script filename is undefined for "/src/contentScript.tsx"
at Object.renderCrxManifest (file://.../node_modules/@crxjs/vite-plugin/dist/index.mjs:1851:25)
at Object.generateBundle (file://.../node_modules/@crxjs/vite-plugin/dist/index.mjs:1629:60)
at async Bundle.generate (file://.../node_modules/rollup/dist/es/shared/node-entry.js:17806:9)
at async file://.../node_modules/rollup/dist/es/shared/node-entry.js:26652:27
at async catchUnfinishedHookActions (file://.../node_modules/rollup/dist/es/shared/node-entry.js:25785:16)
at async Promise.all (index 0)
at async Task.run (file://.../node_modules/rollup/dist/es/shared/watch.js:4798:32)
at async Watcher.run (file://.../node_modules/rollup/dist/es/shared/watch.js:4725:13)
[crx:manifest-post] Error in crx:web-accessible-resources.renderCrxManifest
Build tool
Vite
Where do you see the problem?
Describe the bug
I'm using the vite plugin with Vite 4.4.9. I want to inject a content script when the user clicks on the action button:
I haven't added the content script to the
manifest.json
because it shouldn't be injected by default, only when the user clicks on the action button.The above works, but whenever I change the file while vite is running with
--watch
, I get an error (see below) and the build fails.Reproduction
Unfortunately the repo is private, but it can be reproduced with the above service worker script and an empty content script.
manifest.json:
```json { "manifest_version": 3, "version": "1.0.0", "name": "Draw on page", "description": "Add drawings on the page", "icons": { "16": "assets/icon.png", "48": "assets/icon.png", "128": "assets/icon.png" }, "background": { "service_worker": "src/background.ts" }, "action": { "default_title": "Draw" }, "permissions": ["scripting"], "host_permissions": ["vite.config.ts:
```ts import { defineConfig } from 'vite'; import { crx } from '@crxjs/vite-plugin'; import manifest from './manifest.json'; export default defineConfig(config => ({ plugins: [crx({ manifest })], })); ```Logs
System Info
Severity
annoyance