diff --git a/src/types/external.ts b/src/types/external.ts index 736af75c..84e1741c 100644 --- a/src/types/external.ts +++ b/src/types/external.ts @@ -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; diff --git a/src/utils/getInternalConfig.ts b/src/utils/getInternalConfig.ts index 98b27167..59387faf 100644 --- a/src/utils/getInternalConfig.ts +++ b/src/utils/getInternalConfig.ts @@ -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; diff --git a/src/utils/globals.ts b/src/utils/globals.ts index d966a373..bfb585bc 100644 --- a/src/utils/globals.ts +++ b/src/utils/globals.ts @@ -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`, + }, ]; } diff --git a/src/utils/manifest.ts b/src/utils/manifest.ts index bfdb626a..ef2af805 100644 --- a/src/utils/manifest.ts +++ b/src/utils/manifest.ts @@ -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', );