-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
45 lines (41 loc) · 1.42 KB
/
vite.config.ts
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
import fs from "fs";
import { defineConfig } from "vite";
import solidPlugin from "vite-plugin-solid";
import path from "node:path";
import { fromEnv } from "@nordicsemiconductor/from-env";
const { version: defaultVersion, homepage } = JSON.parse(
fs.readFileSync(path.join(process.cwd(), "package.json"), "utf-8")
);
const version = process.env.VERSION ?? defaultVersion;
const { confirmEmailURL, requestTokenAPI, registerAPI } = fromEnv({
confirmEmailURL: "CONFIRM_EMAIL_API",
requestTokenAPI: "REQUEST_TOKEN_API",
registerAPI: "REGISTER_API",
})(process.env);
const sentryDSN = process.env.SENTRY_DSN ?? "";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [solidPlugin()],
base: `${(process.env.BASE_URL ?? "").replace(/\/+$/, "")}/`,
preview: {
host: "localhost",
port: 8080,
},
server: {
host: "localhost",
port: 8080,
},
// string values will be used as raw expressions, so if defining a string constant, it needs to be explicitly quoted
define: {
HOMEPAGE: JSON.stringify(homepage),
VERSION: JSON.stringify(version ?? Date.now()),
BUILD_TIME: JSON.stringify(new Date().toISOString()),
CONFIRM_EMAIL_API: JSON.stringify(confirmEmailURL),
REQUEST_TOKEN_API: JSON.stringify(requestTokenAPI),
REGISTER_API: JSON.stringify(registerAPI),
SENTRY_DSN: JSON.stringify(sentryDSN),
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
},
});