feat: Add more supported browser types
This commit is contained in:
@@ -37,7 +37,7 @@ export interface WxtDevServer extends vite.ViteDevServer {
|
||||
origin: string;
|
||||
}
|
||||
|
||||
export type TargetBrowser = 'chromium' | 'firefox';
|
||||
export type TargetBrowser = 'chrome' | 'firefox' | 'safari' | 'edge' | 'opera';
|
||||
export type TargetManifestVersion = 2 | 3;
|
||||
|
||||
export type UserConfig = Omit<InlineConfig, 'configFile'>;
|
||||
|
||||
@@ -19,9 +19,9 @@ export async function getInternalConfig(
|
||||
const root = config.root ? path.resolve(config.root) : process.cwd();
|
||||
const mode =
|
||||
config.mode ?? (command === 'build' ? 'production' : 'development');
|
||||
const browser = config.browser ?? 'chromium';
|
||||
const browser = config.browser ?? 'chrome';
|
||||
const manifestVersion =
|
||||
config.manifestVersion ?? (browser === 'chromium' ? 3 : 2);
|
||||
config.manifestVersion ?? (browser == 'firefox' ? 2 : 3);
|
||||
const outBaseDir = path.resolve(root, '.output');
|
||||
const outDir = path.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
|
||||
const logger = config.logger ?? consola;
|
||||
|
||||
+17
-2
@@ -15,8 +15,8 @@ export function getGlobals(
|
||||
type: `"chromium" | "firefox"`,
|
||||
},
|
||||
{
|
||||
name: '__IS_CHROMIUM__',
|
||||
value: config.browser === 'chromium',
|
||||
name: '__IS_CHROME__',
|
||||
value: config.browser === 'chrome',
|
||||
type: `boolean`,
|
||||
},
|
||||
{
|
||||
@@ -24,5 +24,20 @@ export function getGlobals(
|
||||
value: config.browser === 'firefox',
|
||||
type: `boolean`,
|
||||
},
|
||||
{
|
||||
name: '__IS_SAFARI__',
|
||||
value: config.browser === 'safari',
|
||||
type: `boolean`,
|
||||
},
|
||||
{
|
||||
name: '__IS_EDGE__',
|
||||
value: config.browser === 'edge',
|
||||
type: `boolean`,
|
||||
},
|
||||
{
|
||||
name: '__IS_OPERA__',
|
||||
value: config.browser === 'opera',
|
||||
type: `boolean`,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ function addEntrypoints(
|
||||
browser_style:
|
||||
config.browser === 'firefox' ? options.options.browserStyle : undefined,
|
||||
chrome_style:
|
||||
config.browser === 'chromium' ? options.options.chromeStyle : undefined,
|
||||
config.browser !== 'firefox' ? options.options.chromeStyle : undefined,
|
||||
page,
|
||||
};
|
||||
}
|
||||
@@ -257,12 +257,12 @@ function addEntrypoints(
|
||||
// ...defaultSidepanel.options,
|
||||
default_panel: page,
|
||||
};
|
||||
} else if (config.browser === 'chromium' && config.manifestVersion === 3) {
|
||||
} else if (config.manifestVersion === 3) {
|
||||
// @ts-expect-error: Untyped
|
||||
manifest.side_panel = {
|
||||
default_path: page,
|
||||
};
|
||||
} else if (config.browser === 'chromium') {
|
||||
} else {
|
||||
config.logger.warn(
|
||||
'Side panel not supported by Chromium using MV2. side_panel.default_path was not added to the manifest',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user