mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-09 20:01:15 +02:00
151 lines
5 KiB
TypeScript
151 lines
5 KiB
TypeScript
import "vite-plus/test/config";
|
|
import { defineConfig } from "vite-plus";
|
|
|
|
import { isDesktopRuntimeExternalDependency } from "../../scripts/lib/desktop-external-packages.ts";
|
|
import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
|
|
|
|
const repoEnv = loadRepoEnv();
|
|
|
|
// The main process is bundled the same way the server CLI is: every JS
|
|
// dependency is inlined and only packages Node must load from disk stay
|
|
// external. The packaged app then installs just those externals, instead of a
|
|
// full production install of apps/desktop's dependency tree next to a server
|
|
// bundle that already carries its own copy of the same libraries.
|
|
const isMainProcessExternal = (id: string) =>
|
|
id === "electron" || id.startsWith("electron/") || isDesktopRuntimeExternalDependency(id);
|
|
const shouldLaunchElectronAfterPack = process.env.T3CODE_DESKTOP_DEV === "1";
|
|
const publicConfigDefine = {
|
|
__T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__: JSON.stringify(
|
|
repoEnv.T3CODE_CLERK_PUBLISHABLE_KEY?.trim() ?? "",
|
|
),
|
|
};
|
|
|
|
export default defineConfig({
|
|
run: {
|
|
tasks: {
|
|
build: {
|
|
command:
|
|
"node scripts/build-browser-secret.mjs && node scripts/build-preview-annotation-css.mjs && vp pack",
|
|
dependsOn: ["t3#build"],
|
|
cache: false,
|
|
},
|
|
dev: {
|
|
command:
|
|
"node scripts/build-browser-secret.mjs && node scripts/build-preview-annotation-css.mjs && cross-env T3CODE_DESKTOP_DEV=1 vp pack --watch",
|
|
dependsOn: ["t3#build"],
|
|
cache: false,
|
|
},
|
|
"dev:bundle": {
|
|
command:
|
|
"node scripts/build-browser-secret.mjs && node scripts/build-preview-annotation-css.mjs && vp pack --watch",
|
|
cache: false,
|
|
},
|
|
"dev:electron": {
|
|
command: "node scripts/dev-electron.mjs",
|
|
dependsOn: ["t3#build"],
|
|
cache: false,
|
|
},
|
|
},
|
|
},
|
|
pack: [
|
|
{
|
|
format: "cjs",
|
|
outDir: "dist-electron",
|
|
dts: false,
|
|
sourcemap: true,
|
|
outExtensions: () => ({ js: ".cjs" }),
|
|
define: publicConfigDefine,
|
|
outputOptions: { codeSplitting: false },
|
|
entry: ["src/main.ts"],
|
|
clean: true,
|
|
deps: {
|
|
alwaysBundle: (id) => !id.startsWith("node:") && !isMainProcessExternal(id),
|
|
neverBundle: isMainProcessExternal,
|
|
onlyBundle: false,
|
|
},
|
|
...(shouldLaunchElectronAfterPack ? { onSuccess: "node scripts/dev-electron.mjs" } : {}),
|
|
},
|
|
{
|
|
format: "cjs",
|
|
outDir: "dist-electron",
|
|
dts: false,
|
|
sourcemap: true,
|
|
outExtensions: () => ({ js: ".cjs" }),
|
|
define: publicConfigDefine,
|
|
entry: [
|
|
"src/electron/WindowsForegroundFocusWorker.ts",
|
|
"src/snapShot/GlobalShiftShortcutWorker.ts",
|
|
"src/snapShot/RegionSnapShotWorker.ts",
|
|
"src/snapShot/SnapShotAccessibilityWorker.ts",
|
|
],
|
|
clean: false,
|
|
deps: {
|
|
alwaysBundle: (id) => !id.startsWith("node:") && !isMainProcessExternal(id),
|
|
neverBundle: isMainProcessExternal,
|
|
onlyBundle: false,
|
|
},
|
|
},
|
|
{
|
|
// boot.cjs requires the other two at runtime, so all three stay separate files.
|
|
format: "cjs",
|
|
outDir: "dist-electron",
|
|
dts: false,
|
|
sourcemap: true,
|
|
outExtensions: () => ({ js: ".cjs" }),
|
|
entry: ["src/boot.ts", "src/compileCache.ts"],
|
|
clean: false,
|
|
deps: {
|
|
neverBundle: (id) => id === "./main.cjs" || id === "./compileCache.cjs",
|
|
},
|
|
},
|
|
{
|
|
format: "cjs",
|
|
outDir: "dist-electron",
|
|
dts: false,
|
|
sourcemap: true,
|
|
outExtensions: () => ({ js: ".cjs" }),
|
|
define: publicConfigDefine,
|
|
entry: ["src/preload.ts"],
|
|
deps: {
|
|
// Sandboxed Electron preloads cannot reliably resolve package imports
|
|
// from inside the packaged ASAR. Bundle Clerk's preload bridge into the
|
|
// preload artifact instead of leaving a runtime require() behind.
|
|
alwaysBundle: (id) => id === "@clerk/electron" || id.startsWith("@clerk/electron/"),
|
|
},
|
|
},
|
|
{
|
|
format: "cjs",
|
|
outDir: "dist-electron",
|
|
dts: false,
|
|
sourcemap: true,
|
|
outExtensions: () => ({ js: ".cjs" }),
|
|
entry: ["src/preview-pick-preload.ts"],
|
|
deps: {
|
|
alwaysBundle: (id) => id === "react-grab" || id.startsWith("react-grab/"),
|
|
},
|
|
},
|
|
{
|
|
format: "cjs",
|
|
outDir: "dist-electron",
|
|
dts: false,
|
|
sourcemap: true,
|
|
outExtensions: () => ({ js: ".cjs" }),
|
|
entry: ["src/preview-pip-preload.ts"],
|
|
},
|
|
{
|
|
// Sandboxed preloads must be self-contained, without shared runtime chunks.
|
|
format: "cjs",
|
|
outDir: "dist-electron",
|
|
dts: false,
|
|
sourcemap: true,
|
|
outExtensions: () => ({ js: ".cjs" }),
|
|
entry: ["src/mac-permission-preload.ts"],
|
|
},
|
|
],
|
|
test: {
|
|
// The Windows lane runs workspace suites concurrently; filesystem-heavy
|
|
// desktop integration tests can exceed Vitest's 5 second default there.
|
|
testTimeout: 15_000,
|
|
setupFiles: ["../../packages/shared/src/testing/longTempDir.ts"],
|
|
},
|
|
});
|