import type { Plugin } from "vite"; // Use a more flexible Plugin type that accommodates different Vite versions // by making hotUpdate optional with any signature type VitePlugin = Plugin & { hotUpdate?: any; }; type WebAccessibleDefinition = | { matches: string[]; extensionIds?: string[]; excludeEntryFile?: boolean; } | { matches?: string[]; extensionIds: string[]; excludeEntryFile?: boolean; }; type AdditionalInput = | string | { fileName: string; webAccessible: boolean | WebAccessibleDefinition; }; type NormalizedAdditionalInput = { fileName: string; webAccessible: WebAccessibleDefinition | null; }; export interface ViteWebExtensionOptions { /** * The manifest file to use as a base for the generated extension */ manifest: chrome.runtime.Manifest; /** * Sets the use_dynamic_url property on web accessible resources generated by the plugin * Default: true */ useDynamicUrlWebAccessibleResources?: boolean; /** * On build, in Manifest V3, merge web accessible resource definitions that have matching non-`resource` properties and dedupe and sort `resources`. In Manifest V2, sort web accessible resources. * Default: true */ optimizeWebAccessibleResources?: boolean; /** * Additional input files that should be processed and treated as web extension inputs. * Useful for dynamically injected scripts and dynamically opened HTML pages. * The webAccessible option configures whether the entry file and its dependencies are included in the manifest `web_accessible_resources` property. Defaults to true. * When set to `true`, defaults to: ```ts { matches: [''], excludeEntryFile: false, } ``` * The `excludeEntryFile` option prevents the entry file from being added as a web accessible resource. Defaults to false. */ additionalInputs?: { scripts?: AdditionalInput[]; html?: AdditionalInput[]; styles?: AdditionalInput[]; }; } /** * Build cross platform, module-based web extensions using vite */ export default function webExtension( options?: ViteWebExtensionOptions ): VitePlugin;