-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvite.config.ts
More file actions
105 lines (101 loc) · 3.02 KB
/
vite.config.ts
File metadata and controls
105 lines (101 loc) · 3.02 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
import { dirname, extname, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import {
defineConfig,
type UserConfig,
type UserConfigFn,
type UserConfigFnObject,
type UserConfigFnPromise,
} from "vite";
import { glob } from "glob";
import { analyzer } from "vite-bundle-analyzer";
import dts from "vite-plugin-dts";
import { codecovVitePlugin } from "@codecov/vite-plugin";
import pkg from "./package.json";
const __dirname = dirname(fileURLToPath(import.meta.url));
const DEFAULT_PROXY_URL = "http://localhost:3000";
const DEFAULT_WSS_PROXY_URL = "ws://localhost:3000";
const config: UserConfig &
Promise<UserConfig> &
UserConfigFnObject &
UserConfigFnPromise &
UserConfigFn = defineConfig({
plugins: [
process.env.ANALYZE ? analyzer() : undefined,
dts({ tsconfigPath: "./tsconfig.build.json" }),
codecovVitePlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: "@algorandfoundation/liquid-client",
uploadToken: process.env.CODECOV_TOKEN,
}),
],
resolve: {
alias: {
"@algorandfoundation/liquid-client": resolve(__dirname, "./src"),
"@algorandfoundation/liquid-client/assertion": resolve(__dirname, "./src/assertion"),
"@algorandfoundation/liquid-client/encoding": resolve(__dirname, "./src/encoder"),
},
},
server: {
allowedHosts: [".dev"],
proxy: {
"^/auth/.*": process.env.PROXY_URL || DEFAULT_PROXY_URL,
"^/.well-known/.*": process.env.PROXY_URL || DEFAULT_PROXY_URL,
"^/connect/.*": process.env.PROXY_URL || DEFAULT_PROXY_URL,
"^/attestation/.*": process.env.PROXY_URL || DEFAULT_PROXY_URL,
"^/assertion/.*": process.env.PROXY_URL || DEFAULT_PROXY_URL,
"/socket.io": {
target: process.env.WSS_PROXY_SERVER || DEFAULT_WSS_PROXY_URL,
ws: true,
},
},
},
build: {
minify: false,
sourcemap: true,
copyPublicDir: false,
emptyOutDir: true,
lib: {
entry: resolve(__dirname, "src/index.ts"),
formats: ["es"],
},
outDir: "lib",
rollupOptions: {
external: Object.keys(pkg.dependencies),
input: Object.fromEntries(
glob
.sync("src/**/*.ts", {
ignore: [
"**/test/**",
"**/*.test.ts",
"**/*.fixtures.ts",
"**/*.spec.ts",
"**/*.bench.ts",
],
})
.map((file) => {
return [
relative("src", file.slice(0, file.length - extname(file).length)),
fileURLToPath(new URL(file, import.meta.url)),
];
}),
),
output: {
compact: false,
preserveModules: true,
entryFileNames: "[name].js",
},
},
},
test: {
coverage: {
exclude: ["*.bench.ts", "main.ts", "test", "vite.config.ts"],
},
browser: {
enabled: false,
provider: "playwright",
instances: [{ browser: "chromium" }, { browser: "firefox" }, { browser: "webkit" }],
},
},
});
export default config;