Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extension reloading webpack plugin #87

Merged
merged 2 commits into from
Jul 10, 2024
Merged

Conversation

turbocrime
Copy link
Contributor

@turbocrime turbocrime commented Jul 3, 2024

this adds a webpack plugin that

  1. creates a local profile
  2. provides extension reloading

content scripts can't re-inject, so you'll still have to reload pages.

you can activate the plugin by specifying a chromium profile directory, either outside the repository or at the conveniently gitignored 'chromium-profile'

CHROMIUM_PROFILE='chromium-profile' pnpm dev

@turbocrime turbocrime requested review from TalDerei and a team July 3, 2024 06:39
Copy link

changeset-bot bot commented Jul 3, 2024

⚠️ No Changeset found

Latest commit: 6c63dfe

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines 48 to 68
const WebExtReloadPlugin = {
webExtRun: undefined as IExtensionRunner | undefined,
apply({ hooks }: webpack.Compiler) {
hooks.afterEmit.tapPromise(
{ name: 'WebExt Reloader' },
async ({ options }: webpack.Compilation) => {
await this.webExtRun?.reloadAllExtensions();
this.webExtRun ??= await WebExtCmd.run({
target: 'chromium',
keepProfileChanges: Boolean(CHROMIUM_PROFILE),
chromiumProfile: CHROMIUM_PROFILE,
profileCreateIfMissing: Boolean(CHROMIUM_PROFILE),
sourceDir: options.output.path,
startUrl: 'https://localhost:5173/',
});
this.webExtRun.registerCleanup(() => (this.webExtRun = undefined));
},
);
},
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is much like the small webpack plugin in the initial transport-demo

async ({ options }: webpack.Compilation) => {
await this.webExtRun?.reloadAllExtensions();
this.webExtRun ??= await WebExtCmd.run({
target: 'chromium',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target is labelled 'chromium' but it will execute actual Chrome by default

@turbocrime turbocrime merged commit e8f4891 into main Jul 10, 2024
3 checks passed
@turbocrime turbocrime deleted the turbocrime/web-ext-plugin branch July 10, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants