-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
30 lines (28 loc) · 903 Bytes
/
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
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr";
import path from "path";
export default defineConfig(({ mode }) => {
// Ref: https://github.com/vitejs/vite/issues/3105#issuecomment-939703781
const env = loadEnv(mode, "env", "");
const htmlPlugin = () => ({
name: "html-transform",
transformIndexHtml: (html: string) =>
html.replace(
/<%=\s*([a-zA-Z_]+)\s*%>/g,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(_match, variableName) => env[variableName]
),
});
return {
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
plugins: [svgr(), react(), htmlPlugin()],
root: "src",
server: { host: "127.0.0.1", port: 3000 },
};
});