crxjs / chrome-extension-tools

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

Ability to have stable extension ID in dev mode #764

Closed jared-figma closed 1 year ago

jared-figma commented 1 year ago

Describe the problem

Hi! First off, thanks for all your work on CRXJS--it's a really cool tool.

I'm working on an extension for some internal developer tooling. We have Chrome policies restricting which extensions we can load (specifically, an ExtensionInstallAllowlist policy, which specifies a list of extension IDs that can be loaded).

When I run npm run dev on an extension scaffolded with the CRXJS Vite plugin, I don't see the extension in Chrome, likely because it has been denied by this policy. I am able to take the output of npm run build and pack that with our private key, and then can load the packed version of the extension (since it now has a deterministic and allow-listed ID). However, this workaround unfortunately means that we can't take advantage of any of the conveniences of the dev server.

Describe the proposed solution

Is there any way to have the dev extension have a stable extension ID (specifying it somehow, or being able to supply a private key so that the ID works in the same way as when it's packed)?

Alternatives considered

It looks like Plasmo does support this (https://www.plasmo.com/blog/posts/how-to-create-a-consistent-id-for-your-chrome-extension), so I'm looking into using that.

Alternately, we can continue to build and pack the extension in development, but at that point it's not much better than our pre-CRXJS workflow.

Importance

i cannot use RPCE without it

AmySteam commented 1 year ago

Have you tried setting the key in the manifest? All you have to do is upload a zip file to the developer console, copy the key and set it on the manifest.

Here's more explicit instructions

Hope this helps 😄

jared-figma commented 1 year ago

Thanks @AmySteam--I think I was just getting confused by another managed Chrome policy that prevented me from loading unpacked extensions. After I got that changed on my Chrome, everything is working as intended!

Closing this issue for now since it isn't really a feature request anymore, but could be worth potentially adding to the docs somewhere?