webpack-run-chrome-extension
Version:
Run your extension on Google Chrome with auto-reload support
51 lines (47 loc) • 2.19 kB
TypeScript
import webpack from 'webpack';
interface RunChromeExtensionInterface extends PluginOptions {
manifestPath?: string;
extensionPath?: string;
stats?: StatsPreset;
}
interface PluginOptions {
port?: number;
browserFlags?: string[];
userDataDir?: string;
startingUrl?: string;
autoReload?: boolean | 'background';
}
type StatsPreset = boolean | 'errors-only' | 'errors-warnings' | 'minimal' | 'none' | 'normal' | 'verbose' | 'detailed' | 'summary';
declare class RunChromeExtension {
private readonly options;
constructor(options: RunChromeExtensionInterface);
/**
* RunChromeExtension works by creating a WebSockets server
* that listens to changes triggered by the user extension
* via webpack. When a change is detected, the server sends
* a message to an extension called reload-extension, which
* is injected into the browser. This extension is responsible
* for sending messages to the user extension. We do that by
* injecting a script into the background page that listens
* to messages from the reload-extension. The HMR part is
* done by webpack-target-webextension, which patches the
* manifest file and modifies the background script to accept
* both extension runtime updates (service_worker, manifest.json)
* and HMR updates (background, content scripts).
*
* Features supported:
* - HTML from the manifest file (action, options_ui, etc) - HMR enabled
* - CSS/JS from the HTML file - HMR enabled
* - Changes in assets from an HTML file - HMR enabled
* - Background script - HMR enabled
* - Content scripts (js) - HMR enabled
* - Content scripts (css) - HMR enabled
* - Context Menu (API) - Full extension reload (chrome.runtime.reload)
* - declarative_net_request (API) - Full extension reload (chrome.runtime.reload)
* - _locales - Full extension reload (chrome.runtime.reload)
* - Service worker - Full extension reload (chrome.runtime.reload)
* - manifest.json - Full extension reload (chrome.runtime.reload)
*/
apply(compiler: webpack.Compiler): void;
}
export { RunChromeExtension as default };