-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
48 lines (44 loc) · 1.23 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
46
47
48
import {defineConfig} from "vitest/config";
import react from "@vitejs/plugin-react";
import {getViteConfig} from "./src/_server/helpers.ts";
import {visualizer} from "rollup-plugin-visualizer";
import type {PluginOption} from "vite";
export default ({mode}) => {
const {VITE_BASE_URL, VITE_LOCAL_PORT, VITE_LOCAL_SERVER_PORT} =
getViteConfig(mode);
const PROD = mode === "production";
if (!VITE_BASE_URL)
throw new Error("vite.config: VITE_BASE_URL is undefined");
if (!PROD) {
if (!VITE_LOCAL_PORT)
throw new Error("vite.config: VITE_LOCAL_PORT is undefined");
if (!VITE_LOCAL_SERVER_PORT)
throw new Error("vite.config: VITE_LOCAL_SERVER_PORT is undefined");
}
return defineConfig({
base: VITE_BASE_URL,
plugins: [
react(),
visualizer({
filename: `./build/stats.html`,
// open: true,
gzipSize: true,
brotliSize: true,
}) as PluginOption,
],
server: {
port: parseInt(VITE_LOCAL_PORT, 10),
},
preview: {
port: parseInt(VITE_LOCAL_SERVER_PORT, 10),
},
build: {
outDir: "build",
},
test: {
environment: "jsdom",
setupFiles: ["./src/tests/vitestSetup.ts"],
globals: true,
},
});
};