mirror of
https://github.com/ilyhalight/voice-over-translation.git
synced 2026-04-26 10:31:28 +00:00
Switch Chrome extension packaging to .zip in CI and release workflows and add 1.11.4 distribution artifacts (chrome .zip, firefox .xpi, updated user scripts). Large source changes include a refactor/extension of the subtitles subsystem (new inlineStyle, activeCues, textSpacing, etc.), new video lifecycle host and auth refresh messaging, added background notifications/storage and bridge XHR/runtime modules, translation playback and smart-ducking runtime modules, multiple type additions and a Node crypto shim, plus numerous UI and localization updates. Also update build and Vite configs and other miscellaneous fixes across the codebase to prepare the release.
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { type InlineConfig, mergeConfig, type UserConfig } from "vite";
|
|
|
|
type DefineValue =
|
|
| string
|
|
| number
|
|
| boolean
|
|
| null
|
|
| readonly DefineValue[]
|
|
| { readonly [key: string]: DefineValue };
|
|
|
|
export const rootDir = fileURLToPath(new URL(".", import.meta.url));
|
|
export const srcDir = path.resolve(rootDir, "src");
|
|
export const distDir = path.resolve(rootDir, "dist");
|
|
export const testsDir = path.resolve(rootDir, "tests");
|
|
|
|
const sharedConfig = {
|
|
resolve: {
|
|
alias: {
|
|
"node:crypto": path.resolve(srcDir, "shims", "nodeCrypto.ts"),
|
|
},
|
|
},
|
|
css: {
|
|
transformer: "lightningcss",
|
|
},
|
|
build: {
|
|
copyPublicDir: false,
|
|
reportCompressedSize: false,
|
|
cssMinify: "lightningcss",
|
|
},
|
|
} satisfies UserConfig;
|
|
|
|
export type ViteDefine = NonNullable<UserConfig["define"]>;
|
|
|
|
export function createViteConfig(config: InlineConfig): InlineConfig;
|
|
export function createViteConfig(config: UserConfig): UserConfig;
|
|
export function createViteConfig(
|
|
config: InlineConfig | UserConfig,
|
|
): InlineConfig | UserConfig {
|
|
return mergeConfig(
|
|
sharedConfig as Record<string, unknown>,
|
|
config as Record<string, unknown>,
|
|
) as InlineConfig | UserConfig;
|
|
}
|
|
|
|
export function defineConstants(
|
|
constants: Record<string, DefineValue>,
|
|
): ViteDefine {
|
|
return Object.fromEntries(
|
|
Object.entries(constants).map(([key, value]) => [
|
|
key,
|
|
typeof value === "string" ? JSON.stringify(value) : value,
|
|
]),
|
|
);
|
|
}
|