forked from Prompt-Hash-Stellar/prompt-hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
114 lines (110 loc) · 3.08 KB
/
Copy pathvite.config.ts
File metadata and controls
114 lines (110 loc) · 3.08 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import wasm from "vite-plugin-wasm";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import { securityHeadersPlugin } from "./scripts/vite-security-headers.mjs";
import path from "path";
// https://vite.dev/config/
export default defineConfig(() => {
const vendorChunks: Record<string, string[]> = {
"vendor-react": ["react", "react-dom", "react-router-dom"],
"vendor-radix": [
"@radix-ui/react-avatar",
"@radix-ui/react-dialog",
"@radix-ui/react-dropdown-menu",
"@radix-ui/react-progress",
"@radix-ui/react-select",
"@radix-ui/react-slider",
"@radix-ui/react-slot",
"@radix-ui/react-tabs",
"@radix-ui/react-tooltip",
],
"vendor-stellar": [
"@stellar/stellar-sdk",
"@stellar/stellar-base",
"@creit.tech/stellar-wallets-kit",
],
"vendor-animation": ["framer-motion"],
"vendor-charts": ["chart.js", "react-chartjs-2"],
"vendor-markdown": ["react-markdown", "remark-gfm", "rehype-sanitize"],
};
// 1. Build out your core stable plugin array matrix
const plugins = [
react(),
nodePolyfills({
include: ["buffer"],
globals: {
Buffer: true,
},
}),
wasm(),
securityHeadersPlugin(),
];
// 2. ONLY dynamic require/inject Sentry if an auth token is physically available in the environment (e.g., inside CI)
if (process.env.SENTRY_AUTH_TOKEN) {
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { sentryVitePlugin } = require("@sentry/vite-plugin");
plugins.push(
sentryVitePlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
telemetry: false,
})
);
} catch (e) {
console.warn("Sentry plugin configuration found but module package files could not be evaluated.");
}
}
return {
plugins,
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"libsodium-wrappers": path.resolve(
__dirname,
"./node_modules/libsodium-wrappers/dist/modules/libsodium-wrappers.js"
),
},
},
build: {
target: "esnext",
sourcemap: true,
rollupOptions: {
output: {
manualChunks(id) {
for (const [chunkName, packages] of Object.entries(vendorChunks)) {
if (
packages.some((pkg) =>
id.includes(`${path.sep}node_modules${path.sep}${pkg}`)
)
) {
return chunkName;
}
}
},
},
},
},
define: {
global: "window",
},
envPrefix: "PUBLIC_",
test: {
environment: "node",
},
server: {
proxy: {
"/friendbot": {
target: "https://friendbot.stellar.org",
changeOrigin: true,
},
"/api": {
target: "http://localhost:5000",
changeOrigin: true,
},
},
},
};
});