-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
vite.config.js
76 lines (69 loc) · 1.83 KB
/
vite.config.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import react from "@vitejs/plugin-react";
import { resolve } from "path";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
const configBuild = {
index: {
entry: resolve(__dirname, "./src/index.ts"),
name: "index",
fileName: "index",
},
hooks: {
entry: resolve(__dirname, "./src/hooks/index.ts"),
name: "hooks",
fileName: "index",
},
themes: {
entry: resolve(__dirname, "./src/themes/index.ts"),
name: "themes",
fileName: "index",
},
validators: {
entry: resolve(__dirname, "./src/validators/index.ts"),
name: "validators",
fileName: "index",
},
};
const currentBuild = configBuild[process.env.ENTRY];
if (currentBuild === undefined) {
throw new Error("ENTRY is undefined or invalid");
}
const configOutput = {
index: "./dist",
hooks: "./dist/hooks",
themes: "./dist/themes",
validators: "./dist/validators",
};
const currentOutput = configOutput[process.env.ENTRY];
if (currentOutput === undefined) {
throw new Error("ENTRY is undefined or invalid");
}
export default defineConfig({
plugins: [dts({ insertTypesEntry: true, skipDiagnostics: true }), react()],
build: {
outDir: currentOutput,
lib: {
...currentBuild,
},
emptyOutDir: process.env.ENTRY === "index" ? true : false,
rollupOptions: {
external: ["react", "react-dom", "react/jsx-runtime"],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
"react/jsx-runtime": "jsxRuntime",
},
},
},
},
resolve: {
alias: {
"@": resolve(__dirname, "./src"),
"@components": resolve(__dirname, "./src/components"),
"@hooks": resolve(__dirname, "./src/hooks"),
"@themes": resolve(__dirname, "./src/themes"),
"@validators": resolve(__dirname, "./src/validators"),
},
},
});