Refactor: support web target without extension plugin

This commit is contained in:
2026-03-10 18:41:59 -07:00
parent 20128386e7
commit 94a00a8816

View File

@@ -1,54 +1,62 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import webExtension from 'vite-plugin-web-extension';
const target = process.env.TARGET || 'firefox'; const target = process.env.TARGET || 'firefox';
export default defineConfig({ export default defineConfig(async () => {
build: { const plugins = [];
outDir: `dist/${target}`,
emptyOutDir: true, if (target !== 'web') {
}, const { default: webExtension } = await import('vite-plugin-web-extension');
plugins:[ plugins.push(
webExtension({ webExtension({
manifest: () => { manifest: () => {
const base = { const base = {
name: "in\u00D8sight", name: "in\u00D8sight",
version: "2.1.0", version: "2.1.0",
author: "planetrenox@pm.me", author: "planetrenox@pm.me",
homepage_url: "https://github.com/planetrenox/inzerosight", homepage_url: "https://github.com/planetrenox/inzerosight",
description: "Communicate undetected in plain sight.", description: "Communicate undetected in plain sight.",
icons: { "48": "icon_500.png" }, icons: { "48": "icon_500.png" },
}; };
if (target === 'chrome') {
return {
...base,
manifest_version: 3,
action: {
default_icon: { "48": "icon_500.png" },
default_title: "in\u00D8sight",
default_popup: "index.html",
},
};
}
if (target === 'chrome') {
return { return {
...base, ...base,
manifest_version: 3, manifest_version: 2,
action: { browser_action: {
default_icon: { "48": "icon_500.png" }, browser_style: false,
default_icon: "icon_500.png",
default_title: "in\u00D8sight", default_title: "in\u00D8sight",
default_popup: "index.html", default_popup: "index.html",
}, },
}; content_security_policy: "script-src 'self'; style-src 'self';",
} browser_specific_settings: {
gecko: {
return { id: "{0a73f41c-c59c-404b-9e07-f7392fa830d4}",
...base, },
manifest_version: 2,
browser_action: {
browser_style: false,
default_icon: "icon_500.png",
default_title: "in\u00D8sight",
default_popup: "index.html",
},
content_security_policy: "script-src 'self'; style-src 'self';",
browser_specific_settings: {
gecko: {
id: "{0a73f41c-c59c-404b-9e07-f7392fa830d4}",
}, },
}, };
}; },
}, })
}), );
], }
return {
build: {
outDir: `dist/${target}`,
emptyOutDir: true,
},
plugins,
};
}); });