-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.config.ts
More file actions
57 lines (52 loc) · 1.29 KB
/
app.config.ts
File metadata and controls
57 lines (52 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { defineConfig } from "@tanstack/react-start/config";
import tsConfigPaths from "vite-tsconfig-paths";
const buildSourcemap = process.env.BUILD_SOURCEMAP === "true";
const CLIENT_SENSITIVE_ENV_PATTERN = /^VITE_.*(KEY|SECRET|TOKEN|PASSWORD)/i;
function preventSensitiveClientEnvLeak() {
return {
name: "prevent-sensitive-client-env-leak",
configResolved() {
const leakedClientSecrets = Object.keys(process.env).filter((envName) =>
CLIENT_SENSITIVE_ENV_PATTERN.test(envName)
);
if (leakedClientSecrets.length === 0) {
return;
}
throw new Error(
`Sensitive env vars cannot use VITE_ prefix: ${leakedClientSecrets.join(", ")}`
);
},
};
}
export default defineConfig({
server: {
preset: "vercel",
rollupConfig: {
external: ["@prisma/client", "prisma"],
},
},
tsr: {
appDirectory: "src",
},
vite: {
build: {
sourcemap: buildSourcemap,
minify: "esbuild",
},
plugins: [
preventSensitiveClientEnvLeak(),
tsConfigPaths({
projects: ["./tsconfig.json"],
}),
],
resolve: {
alias: {
lodash: "lodash-es",
},
},
ssr: {
external: ["@prisma/client", "prisma"],
noExternal: ["lodash", "lodash-es", "recharts"],
},
},
});