-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
|
apps/extension/webpack.config.ts
Outdated
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)); | ||
}, | ||
); | ||
}, | ||
}; | ||
|
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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
c26fd34
to
6c63dfe
Compare
this adds a webpack plugin that
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