-
Notifications
You must be signed in to change notification settings - Fork 452
Expand file tree
/
Copy pathvite.config.ts
More file actions
60 lines (56 loc) · 1.7 KB
/
vite.config.ts
File metadata and controls
60 lines (56 loc) · 1.7 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
import path from "node:path";
import { cloudflare } from "@cloudflare/vite-plugin";
import { paraglideVitePlugin } from "@inlang/paraglide-js";
import tailwindcss from "@tailwindcss/vite";
import { devtools } from "@tanstack/devtools-vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import viteReact from "@vitejs/plugin-react";
import { defineConfig, loadEnv } from "vite";
import viteTsConfigPaths from "vite-tsconfig-paths";
import { z } from "zod";
import packageJson from "./package.json";
import { themeNames, themes } from "./src/features/theme/registry";
const buildEnvSchema = z.object({
THEME: z.enum(themeNames).catch("default"),
});
const config = defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const buildEnv = buildEnvSchema.parse(env);
return {
define: {
__APP_VERSION__: JSON.stringify(packageJson.version),
__THEME_NAME__: JSON.stringify(buildEnv.THEME),
__THEME_CONFIG__: JSON.stringify(themes[buildEnv.THEME]),
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@theme": path.resolve(
__dirname,
`src/features/theme/themes/${buildEnv.THEME}`,
),
},
},
plugins: [
paraglideVitePlugin({
project: "./project.inlang",
outdir: "./src/paraglide",
strategy: ["cookie", "preferredLanguage", "baseLocale"],
cookieName: "LOCALE",
}),
cloudflare({
viteEnvironment: {
name: "ssr",
},
}),
viteTsConfigPaths({
projects: ["./tsconfig.json"],
}),
tailwindcss(),
devtools(),
tanstackStart(),
viteReact(),
],
};
});
export default config;