-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
55 lines (51 loc) · 1.58 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
53
54
55
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";
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
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
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
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:
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
env.VITE_APP_ENV === "prod"
? [
"console",
// 'debugger'
]
: [],
},
} as UserConfig & { test: VitestUserConfig["test"] });
};