-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
35 lines (34 loc) · 858 Bytes
/
vite.config.ts
File metadata and controls
35 lines (34 loc) · 858 Bytes
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
import reactRefresh from "@vitejs/plugin-react-refresh";
import { defineConfig, loadEnv } from "vite";
import eslintPlugin from "vite-plugin-eslint";
import svgr from "vite-plugin-svgr";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, "./");
const htmlEnvPlugin = () => {
return {
name: "html-transform",
transformIndexHtml(html: string) {
return html.replace(/<%=(.*?)%>/g, function (match, p1) {
return env[p1];
});
},
};
};
return {
base: "./",
// This changes the out put dir @from dist to build
// comment this out if that isn't relevant for your project
build: {
outDir: "build",
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
plugins: [reactRefresh(), svgr(), eslintPlugin(), htmlEnvPlugin()],
};
});