Closed thdoan closed 1 year ago
UPDATE: I tried commenting out the CrxPlugin code above and manually updated manifest.json
(see below), and it's giving me the same error.
...
"web_accessible_resources": [
{
"matches": ["<all_urls>"],
"resources": [
"test.html"
]
}
]
Hmm...maybe something else is going on because this is a perfectly valid code since test.html
is correctly built to root via the config below.
vite.config.ts
...
build: {
rollupOptions: {
input: {
test: './src/test/test.html',
},
},
},
plugins: [
svelte(),
crx({ manifest }),
{
...renameFile('src/popup/popup.html', 'popup.html'),
apply: 'build',
},
{
...renameFile('src/test/test.html', 'test.html'),
apply: 'build',
}
],
Hi @thdoan 👋 I'm a little confused here, it's hard to know what's going on here without a minimal reproduction repo.
For files in web_accessible_resources
, CRXJS first checks if a file has already been emitted by another plugin, if not it directly copies the file to the output folder. That error means that there was no file to copy at that file path.
It's possible to make a plugin that would emit a file to another location, you might dig through CRXJS code for an example. Search for the CRXJS plugin hook renderCrxManifest
for examples.
@jacksteamdev I put together a minimal reproduction repo for you here:
https://stackblitz.com/edit/vitejs-vite-rkrb7p?file=vite.config.ts
When you run npm run build
in the terminal, it will build with popup.html
moved to root.
Issue: how do I get it to output the config below in manifest.json
to match the new location of popup.html
?
"web_accessible_resources": [
{
"resources": [
"popup.html"
]
}
]
I tried to change it directly in the FOR loop, but it errored out. You can uncomment the FOR block to see.
Since I decided to show the popup inside an iframe instead of using chrome.action
, this is no longer relevant.
Build tool
Vite
Where do you see the problem?
Describe the bug
The CrxPlugin works great for renaming
manifest.action.default_popup
files, but I just found out it's not able to rename items insidemanifest.web_accessible_resources
. Let's say I want to renamesrc/test/test.html
totest.html
(and assume it's already building correctly todist
root)...Sample manifest.json
CrxPlugin
The code above returns this error in the build output:
Reproduction
N/A
Logs
No response
System Info
Severity
annoyance