forked from xieQin/genius-invokation-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
40 lines (37 loc) · 1.06 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
import replace from "@rollup/plugin-replace";
import legacy from "@vitejs/plugin-legacy";
import react from "@vitejs/plugin-react";
import { fileURLToPath } from "url";
import { defineConfig, loadEnv, PluginOption } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import { PWAConfig, replaceOptions } from "./src/configs/pwa";
// https://vitejs.dev/config/
export default ({ mode }: { mode: string }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
build: {
sourcemap: process.env.SOURCE_MAP === "true",
},
plugins: [
legacy(),
react(),
VitePWA(PWAConfig),
replace(replaceOptions) as PluginOption,
],
resolve: {
alias: {
// for TypeScript path alias import like : @/x/y/z
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
proxy: {
"/api": {
target: "http://localhost:8080",
secure: false,
rewrite: path => path.replace(/^\/api/, ""),
},
},
},
});
};