Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export function createWebExtRunner(

const initialConfig = await loadConfig({ pluginOptions, logger, paths });
const target =
pluginOptions.browser === null || pluginOptions.browser === "firefox"
? null
: "chromium";
pluginOptions.browser === "chrome"
? "chromium"
: pluginOptions.browser === null ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if we should deprecate the browser: null setting. It's a bit cryptic 😅

Copy link
Owner

Choose a reason for hiding this comment

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

Huh, yeah, wonder what I was thinking lol. Let's leave it for now.

pluginOptions.browser === "firefox"
? "firefox-desktop"
: initialConfig.target ?? "chromium";

const sourceDir = paths.outDir;
const config = {
Expand Down
4 changes: 2 additions & 2 deletions packages/vite-plugin-web-extension/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface UserOptions {
*
* @default "chrome"
*/
browser?: string;
browser?: 'chrome' | 'firefox' | (string & {}) | null;
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 a TypeScript trick that provides auto-completion for some values while still allowing any string

Copy link
Owner

Choose a reason for hiding this comment

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

Interesting, didn't know this worked... I've only used branded types with a property inside the {}. I've always had to use a function overload to get this behavior before, very good to know!


/**
* Do not validate your manifest to make sure it can be loaded by browsers.
Expand Down Expand Up @@ -119,7 +119,7 @@ export interface ResolvedOptions {
additionalInputs: string[];
disableAutoLaunch: boolean;
watchFilePaths: string[];
browser?: string;
browser?: 'chrome' | 'firefox' | (string & {}) | null;
skipManifestValidation: boolean;
printSummary: boolean;
htmlViteConfig?: vite.InlineConfig;
Expand Down