John Gordon
unread,Feb 19, 2025, 10:52:08 AMFeb 19Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions
I’m trying to open a popup window that references an HTML page from my extension code. This works in crxjs but not in wxt. Here’s my code:
```ts
browser.windows.create({
url: chrome.runtime.getURL(
"src/entrypoints/sidePanel/popup/composePopup.html"
),
type: "popup",
focused: true,
});
```
In crxjs, this worked by simply adding the `composePopup.html` to my Vite configuration. I tried doing the same thing in my `wxt.config.ts` file:
```ts
build: {
sourcemap: true,
rollupOptions: {
input: {
composePopup: "src/entrypoints/sidePanel/popup/composePopup.html",
},
},
},
```
I confirmed that the file is being built and shows up in the .output directory:
```zsh
✔ Built extension in 295 ms 9:22:05 AM
├─ .output/chrome-mv3/manifest.json 1.32 kB
├─ .output/chrome-mv3/options.html 765 B
├─ .output/chrome-mv3/sidePanel.html 705 B
├─ .output/chrome-mv3/src/entrypoints/sidePanel/popup/composePopup.html 734 B
├─ .output/chrome-mv3/src/entrypoints/sidePanel/popup/composePopup.html 734 B
├─ .output/chrome-mv3/src/entrypoints/sidePanel/popup/composePopup.html 734 B
```
(I’m not sure why it’s listed three times, but there’s only one actual file in the `.output` directory.)
However, in wxt, this isn’t working. The popup window throws an error saying the resource couldn’t be found, or I get:
`Uncaught ReferenceError: background is not defined`
This error goes away if I remove the build object from the Vite configuration, restart wxt, and re-add the extension. (More debug output would be helpful here.)
So, what am I doing wrong? How can I properly include this HTML file so I can open it with browser.windows.create in wxt?