crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.82k stars 188 forks source link

Can not HMR an web-accessible-resources #897

Open coolcorexix opened 3 months ago

coolcorexix commented 3 months ago

Describe the problem

I have this script that have to be attached as script element on host page because I need to register a global component (which can not be done by running the script in the content script). But the script have ReactJs in it so it need to be bundled with vite so that the browser can understand.

Currently I can not get the file to be HMR during development so I have to go through this painful manual procedure instead:

Have CRXJS already supported this without me knowing?

Describe the proposed solution

If possible, please give me the ability to HMR with specified web_resources by registering them in the vite.config.ts

{
...
build: {
rollupOptions: {
input: {
newAlias: "same_path_in_the_manifest"
}
}
}
}

Alternatives considered

I am considering making a separate HMR server while waiting for our discussion

Importance

would make my life easier

Toumash commented 3 months ago

Its just a content script in MAIN world. Some work done here https://github.com/crxjs/chrome-extension-tools/pull/851 and here https://github.com/crxjs/chrome-extension-tools/issues/695. Current state explained in the blogpost https://dev.to/jacksteamdev/advanced-config-for-rpce-3966 in the "main world scrips" chapter