Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

vite.config.ts

76 lines2.5 KB

1import "vite-plus/test/config";
2import { defineConfig, mergeConfig } from "vite-plus";
3​
4import baseConfig from "../../vite.config.ts";
5import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
6import packageJson from "./package.json" with { type: "json" };
7​
8const bundledPackagePrefixes = [
9 "@pierre/diffs",
10 "@t3tools/",
11 "effect-acp",
12 "effect-codex-app-server",
13];
14​
15export function shouldBundleCliDependency(id: string): boolean {
16 return bundledPackagePrefixes.some((prefix) => id.startsWith(prefix));
18​
19const repoEnv = loadRepoEnv();
20const cliBuildChannel = packageJson.version.includes("-nightly.") ? "nightly" : "latest";
21​
22export default mergeConfig(
23 baseConfig,
24 defineConfig({
25 run: {
26 tasks: {
27 build: {
28 command: "node scripts/cli.ts build",
29 dependsOn: ["@t3tools/web#build"],
30 cache: false,
31 },
32 },
33 },
34 pack: {
35 entry: ["src/bin.ts"],
36 outDir: "dist",
37 sourcemap: true,
38 clean: true,
39 deps: {
40 alwaysBundle: shouldBundleCliDependency,
41 onlyBundle: false,
42 },
43 banner: {
44 js: "#!/usr/bin/env node\n",
45 },
46 define: {
47 __T3CODE_BUILD_CHANNEL__: JSON.stringify(cliBuildChannel),
48 __T3CODE_BUILD_RELAY_URL__: JSON.stringify(repoEnv.T3CODE_RELAY_URL?.trim() ?? ""),
49 __T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__: JSON.stringify(
50 repoEnv.T3CODE_CLERK_PUBLISHABLE_KEY?.trim() ?? "",
51 ),
52 __T3CODE_BUILD_CLERK_CLI_OAUTH_CLIENT_ID__: JSON.stringify(
53 repoEnv.T3CODE_CLERK_CLI_OAUTH_CLIENT_ID?.trim() ?? "",
54 ),
55 __T3CODE_BUILD_RELAY_CLIENT_OTLP_TRACES_URL__: JSON.stringify(
56 repoEnv.T3CODE_RELAY_CLIENT_OTLP_TRACES_URL?.trim() ?? "",
57 ),
58 __T3CODE_BUILD_RELAY_CLIENT_OTLP_TRACES_DATASET__: JSON.stringify(
59 repoEnv.T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET?.trim() ?? "",
60 ),
61 __T3CODE_BUILD_RELAY_CLIENT_OTLP_TRACES_TOKEN__: JSON.stringify(
62 repoEnv.T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN?.trim() ?? "",
63 ),
64 },
65 },
66 test: {
67 // The server suite exercises sqlite, git, temp worktrees, and orchestration
68 // runtimes heavily. Running files in parallel introduces load-sensitive flakes.
69 fileParallelism: false,
70 // Server integration tests exercise sqlite, git, and orchestration together.
71 // Under package-wide runs they can exceed the default budget on loaded CI hosts.
72 hookTimeout: 120_000,
73 testTimeout: 120_000,
74 },
75 }),
76);