-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
52 lines (48 loc) · 1.33 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
49
50
51
52
import { resolve } from "node:path";
import react from "@vitejs/plugin-react-swc";
import { type UserConfig, defineConfig, loadEnv } from "vite";
import type { UserConfig as VitestUserConfig } from "vitest/dist/config.js";
const createEnv = require("./src/constants/env/create-env").createEnv;
// https://vitejs.dev/config/
export default ({ mode }: { mode: string }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
// validae env vars
const env = createEnv({ runtimeEnv: process.env });
return defineConfig({
plugins: [react()],
server: {
port: 8080,
},
resolve: {
alias: {
"@": resolve(__dirname, "/src"),
},
},
test: {
/**
* グローバルを許可する場合、tsconfig.jsonに以下を追加
* {
* "compilerOptions": {
* ...
* "types": ["vitest/globals"]
* }
*/
globals: false,
environment: "happy-dom",
include: ["src/**/*.test.{js,ts,jsx,tsx}"],
alias: {
"@": resolve(__dirname, "./src"),
},
setupFiles: ["./src/setup-tests.ts"],
},
esbuild: {
drop:
env.VITE_APP_ENV === "prod"
? [
"console",
// 'debugger'
]
: [],
},
} as UserConfig & { test: VitestUserConfig["test"] });
};